trellis:build
Skill2 starsChanged 9 months agoMITView on GitHub
Executes implementation from tasks.json through a check-driven feedback loop. Use when all spec artifacts are ready and implementation should begin.
In this repository18 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- checkSkill
- lintSkill
- testSkill
- versionSkill
- build-with-subagentsSkill
- build-with-batchSkill
- trellis:clarifySkill
- trellis:complianceSkill
- trellis:guidelinesSkill
- trellis:initSkill
- trellis:pitchSkill
- trellis:planSkill
- trellis:prepSkill
- trellis:runSkill
- trellis:sketchSkill
- trellis:specSkill
- trellis:statusSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
29 rules. About 0 are common, 10 are distinctive, and 19 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
19
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
After completing the spec pipeline (pitch → spec → plan → prep)
- Very specific: line 15
When tasks.json exists (or plan.md exists — tasks.json will be auto-generated)
- Very specific: line 33
IMPORTANT: If the user wrote with ralph, you MUST recognize it as an execution mode modifier.
- Very specific: line 37
Read trellis.json to get specsDir (default: .specs)
- Very specific: line 38
Run python3 ${CLAUDE_PLUGIN_ROOT}/scripts/validate-prereqs.py build <feature-name> and use the specsDir value from the JSON output.
- Very specific: line 39
Check if {specsDir}/{feature}/tasks.json exists.
- Distinctive: line 41
If present: Read it and continue.
- Very specific: line 42
If all tasks have status "done" → report completion and stop.
- Very specific: line 43
If the check field is empty → ask the user: "What command should pass for code to be correct?
- Very specific: line 49
Verify the check field in tasks.json is non-empty.
- Very specific: line 54
Use run_in_background: true on the Bash tool.
- Distinctive: line 70
Final summary: When ralph finishes:
- Very specific: line 71
Read final status.json for exit code and counts.
- Very specific: line 73
If any tasks are blocked, list them with IDs and titles from tasks.json.
- Very specific: line 74
If the judge ran, mention the verdict is in logs/ralph-<feature>/judge.log.
- Very specific: line 75
If exitCode is non-zero, show the last 30 lines of output.log.
- Very specific: line 77
If ralphMode == "off": Proceed to the execution loop below.
- Very specific: line 85
Run the check command from tasks.json.
- Distinctive: line 87
If this is the first task and check fails, that's expected (nothing built yet).
- Distinctive: line 88
If this is a subsequent task and check fails, prior work regressed.
- Distinctive: line 95
Output: Test file(s) written to disk.
- Very specific: line 101
Write the code described in the task's do field.
- Very specific: line 110
Run the check command from tasks.json:
- Very specific: line 119
After each task, write the updated tasks.json to disk.
- Very specific: line 123
After all tasks are processed (unless --no-judge was passed):
- Distinctive: line 133
If the judge says PARTIAL or FAIL, fix the specific issues and re-run the check.
- Distinctive: line 148
After the build is functionally complete (or redefinition limit reached), a polish phase runs two review agents sequentially:
- Distinctive: line 152
If either agent created tasks, they're executed in one final task pass (no judge/redefiner after polish).
- Distinctive: line 162
When done (or when stopping due to blocked tasks), report:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Build
Turn specifications into working code through a task-by-task feedback loop. Each task gets tests first (TDD), then implementation, then a check command validates correctness.
When to use
- "build this", "implement this"
- After completing the spec pipeline (pitch → spec → plan → prep)
- When
tasks.jsonexists (or plan.md exists — tasks.json will be auto-generated)
Step 0 — Parse invocation modifiers
Do this FIRST, before any pre-flight scripts or file reads.
Parse the user's invocation for the with ralph suffix and optional flags:
with ralph→ SetralphMode = "ralph". Ralph is a Docker-based loop script that runs each task in a fresh context. Fire-and-forget: the user walks away and comes back when it's done.- No modifier → Set
ralphMode = "off". All tasks run in the current session.
Optional flags (only meaningful in ralph mode):
--silent→ Output goes to log files only; status shown between tasks.--tail→ Show last 50 lines of each iteration's log after it completes.--no-judge→ Skip the judge review at the end.- Neither → Stream mode (default) — full Claude output visible in real-time.
IMPORTANT: If the user wrote with ralph, you MUST recognize it as an execution mode modifier. Never ask "what is ralph?" or treat it as an unknown term.
Pre-flight
- Read
trellis.jsonto getspecsDir(default:.specs) - Run
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/validate-prereqs.py build <feature-name>and use thespecsDirvalue from the JSON output. Abort if prerequisites are missing. - Check if
{specsDir}/{feature}/tasks.jsonexists.- If missing: Tell the user "No tasks.json found — running
/trellis:prepto generate it." Then invoke/trellis:prep <feature-name>. After prep completes, continue with the generated tasks.json. - If present: Read it and continue.
- If missing: Tell the user "No tasks.json found — running
- If all tasks have status
"done"→ report completion and stop. - If the
checkfield is empty → ask the user: "What command should pass for code to be correct? (e.g.,npm run lint && npm run typecheck && npm run build && npm run test)" Write their answer into tasks.json'scheckfield.
Ralph handoff
If ralphMode == "ralph":
- Verify the
checkfield in tasks.json is non-empty. If empty, abort with: "Ralph mode requires a check command. Set it in guidelines.md or run/trellis:build <feature>interactively first." - Launch ralph in the background:
Usebash ${CLAUDE_PLUGIN_ROOT}/scripts/ralph-loop.sh <feature-name> [limit] [flags]run_in_background: trueon the Bash tool. Enter monitoring loop. Ralph writes progress to
logs/ralph-<feature>/status.jsonand output tologs/ralph-<feature>/output.log. Poll every 60 seconds:a. Read
logs/ralph-<feature>/status.json. If the file does not exist yet, ralph is still starting up — wait and retry. b. Display a compact progress block (no extra commentary):Ralph: <feature> | <Xm Ys> elapsed Task <index>/<total> (<id>): <title> [<phase>] Done: <N> | Blocked: <N> | Pending: <N>c. Read the last 10 lines of
logs/ralph-<feature>/output.logusingtail -10and display them in a fenced code block labeled "Recent output". d. Ifstatus.jsonshows"finished": true, exit the monitoring loop. e. If the background process is no longer running (check via TaskOutput) ANDstatus.jsondoes not show"finished": true, assume ralph crashed. Display the last 30 lines ofoutput.logand report the failure. f. Sleep 60 seconds between polls using the Bash tool.- Final summary. When ralph finishes:
- Read final
status.jsonfor exit code and counts. - Display done/blocked/pending totals.
- If any tasks are blocked, list them with IDs and titles from tasks.json.
- If the judge ran, mention the verdict is in
logs/ralph-<feature>/judge.log. - If
exitCodeis non-zero, show the last 30 lines ofoutput.log.
- Read final
If ralphMode == "off": Proceed to the execution loop below.
Execution loop (in-session mode)
For each task in tasks.json where status == "pending", in order:
Step 0: Precondition check
Run the check command from tasks.json. This verifies all previous work is still green.
- If this is the first task and check fails, that's expected (nothing built yet). Skip.
- If this is a subsequent task and check fails, prior work regressed. Fix the regression before proceeding to the next task.
Step 1: Write tests (test-writer agent)
Evaluate the task's verify field. If it describes behavioral expectations (validates input, returns errors, handles edge cases, state transitions), spawn the test-writer agent:
- Input: The task's
verifyanddofields, plus test conventions from guidelines.md - Output: Test file(s) written to disk. The tests should FAIL (the implementation doesn't exist yet).
Skip the test-writer for purely structural verify text (file exists, scaffold created, config set, compiles clean). Use python3 ${CLAUDE_PLUGIN_ROOT}/scripts/should-write-tests.py if unsure.
Step 2: Implement the task
Write the code described in the task's do field. Follow this priority for guidance:
- The task's
dofield — most specific instructions plan.md— technical patterns, file structure, architectureguidelines.md— project-wide conventions- Existing code — style consistency
Step 3: Run check
Run the check command from tasks.json:
- Pass → Update the task's
statusto"done"in tasks.json. Git commit. Proceed to next task. - Fail → Read the error output. Fix the specific issues. Run check again.
- Pass on retry → Mark done, commit, next task.
- Fail on retry → Mark the task's
statusas"blocked"in tasks.json. Git commit. Move to the next task.
Step 4: Write updated tasks.json
After each task, write the updated tasks.json to disk. This is the resume point — if the session is interrupted, re-running /trellis:build <feature> picks up from the first pending task.
Judge review
After all tasks are processed (unless --no-judge was passed):
Spawn the judge agent with:
spec.md— the full specificationtasks.json— showing which tasks are done, blocked, or pendinggit diff --stat— summary of all changes made
The judge evaluates intent alignment: did the implementation satisfy what the spec asked for, not just what the tasks described? It returns a structured verdict (PASS / PARTIAL / FAIL) with per-task assessments and recommendations.
If the judge says PARTIAL or FAIL, fix the specific issues and re-run the check. Limit: 2 judge re-submissions. After that, report to the user with the judge's feedback.
Post-judge redefinition (ralph mode)
In ralph mode, after the judge completes, an automated redefinition loop kicks in if blocked tasks remain or the judge returns PARTIAL/FAIL:
- The redefiner agent reads failure logs and the judge verdict, diagnoses root causes (convention mismatch, environment limitation, logic error, test fragility), and rewrites blocked task
dofields with lessons learned. - The redefiner may add new tasks for judge-identified gaps (using phase N+1 numbering).
- Blocked tasks are reset to
"pending"and the task loop re-executes. - Maximum 3 redefinition passes. After that, ralph stops and reports remaining issues — they likely require human judgment.
During redefinition, status.json shows "currentPhase": "redefining" and includes a redefinitionPass field. Redefiner logs are written to logs/ralph-<feature>/redefiner-pass-N.log.
Post-judge polish phase (ralph mode)
After the build is functionally complete (or redefinition limit reached), a polish phase runs two review agents sequentially:
- The optimizer agent reads the completed implementation and identifies localized performance/simplification opportunities — function-level complexity, redundant computation, component efficiency, and cross-module interaction overhead. It creates up to 5 new tasks (phase N+1) and appends §11 to plan.md.
- The improver agent reads the implementation AND all build logs to identify robustness improvements — fragile patterns that required retries, edge case gaps revealed by check failures, and thin error handling. It creates up to 5 new tasks (phase N+2) and appends §12 to plan.md.
- If either agent created tasks, they're executed in one final task pass (no judge/redefiner after polish).
Both agents are constrained: the optimizer must not change architecture, the improver must stay within spec scope. Neither may add new features. Tasks created by these agents include a "source" field ("optimizer" or "improver") for traceability.
During polish, status.json shows "currentPhase": "optimizing" or "improving". Logs are written to logs/ralph-<feature>/optimizer.log and logs/ralph-<feature>/improver.log.
Opt out with --no-polish. Skipped automatically if --no-judge is set (no judge means no polish).
Reporting
When done (or when stopping due to blocked tasks), report:
- Tasks completed / blocked / remaining
- Files created/modified — brief summary
- Judge verdict — if run
- Remaining work — what's blocked and why
References
references/external-integrations.md— How Ralph mode worksreferences/git-usage.md— Git rules during implementationreferences/sub-agent-strategy.md— Test-writer and judge spawningreferences/error-recovery.md— Resume from interruption
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

