Build Phase

You are implementing a feature for Orcha, a Clojure document processing platform.

Your Task

  1. Read IMPLEMENTATION_PLAN.md in the workspace root
  2. Find the first pending task (marked [ ])
  3. Implement ONLY that task
  4. Verify and commit the changes
  5. Output CONTINUE (or completion marker if done)

Before You Start

Read these files:

Implementation Workflow

1. Read Before Write

Always read files before editing. Understand existing patterns.

2. Make Changes

Follow the code style from CLAUDE.md:

3. Verify Changes

Always compile-check after editing Clojure files:

clojure -M -e "(require 'the.namespace :reload)"

Lint check:

clj-kondo --lint src test --fail-level warning

4. Testing Strategy

Tests are slow (~8 min). Use this tiered approach:

Low-risk changes (compile-check only)

High-risk changes (run selective tests)

Run selective tests:

# Map source ns to test ns: com.getorcha.foo → com.getorcha.foo-test
clj -X:test :nses '[com.getorcha.foo-test]' 2>&1 | grep -E "(FAIL in|ERROR in|Execution error|failed because)"

Phase completion (run full test suite)

When completing the last task of a phase, run the full test suite:

clj -X:test 2>&1 | grep -E "(FAIL in|ERROR in|Execution error|failed because)"

If tests fail at phase end:

  1. Identify which task broke tests
  2. Fix the issue
  3. Commit the fix
  4. Re-run full tests before proceeding to next phase

5. Commit

Stage specific files (NEVER use git add -A or git add .):

git add path/to/specific/file.clj
git commit -m "Description of change"

6. Update Plan

Mark the completed task in IMPLEMENTATION_PLAN.md:

- [x] Task 1: Description

7. Output

If more tasks remain:

CONTINUE

If all tasks are complete, read .ralph/completion-marker.txt and output its contents.

Determining Phase Boundaries

Look at the ## Tasks section in IMPLEMENTATION_PLAN.md. Phases are marked with headers like:

### Phase 1: Configuration & Foundation
### Phase 2: OAuth Library

The last task before the next ### Phase header (or end of tasks) is the phase-end task.

Database Access

AWS Services

Common Patterns

Adding an API endpoint

  1. Define route in router namespace
  2. Create handler function
  3. Add Malli schemas for request/response
  4. Add tests

Database queries

(db.sql/execute! pool
  {:select [:*]
   :from [:table-name]
   :where [:= :column value]})

Creating migrations

bb migrate create "migration-name"

Guardrails