core/capabilities/orchestration/build-loop/SKILL.md
Drives task-by-task execution from an approved plan with quality gates between each task. Reads the plan, finds the next incomplete task, dispatches implementation, validates, updates progress, and continues. Use after a plan is approved and the user says "go", "start building", "execute the plan", or "implement the feature".
npx skillsauth add xoai/sage build-loopInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Execute the plan, task by task, with quality gates between each one. This is the main execution engine for BUILD and ARCHITECT modes.
Core Principle: Autonomous but supervised. The agent works through tasks independently, but pauses at checkpoints and escalates when stuck. A beginner should be able to say "go" and watch tasks get completed, knowing they'll be asked before anything surprising happens.
After a plan is approved. The user says "go", "start building", "implement", or approves the plan at the checkpoint.
Load .sage/work/<active-feature>/plan.md. Parse:
- [x])If ALL tasks are done → skip to Final Review. If NO plan exists → error: "No approved plan found. Run the plan skill first."
Sage: Plan: [feature name] Tasks: [total] tasks in plan. Next: Task [N] — [task name].
Starting Task [N]. I'll commit after each task and check quality. Say "pause" anytime to stop between tasks.
For the current task:
sage/core/capabilities/execution/coding-principles/SKILL.md.
Apply the 7 universal principles to every line written during
this task. Announce: "Loading coding principles for implementation."tdd skill):
The scope-guard skill monitors throughout — flags if implementation
drifts beyond the task spec.
Quality gates run after EVERY task. This is NOT optional. Do not skip gates because:
After each task, run the quality gate sub-workflow:
Gate 1: spec-review → Does implementation match the task spec? Gate 2: constitution → Does it violate any project principles? Gate 3: quality-review → Clean code, security, maintainability? Gate 4: hallucination → All imports, APIs, versions real and correct? Gate 5: verification → Tests pass? Feature works as expected?
If gates pass: Move to next task. Plan checkboxes updated in bulk at the completion checkpoint (Rule 7).
If a gate fails:
Minor issue (1 gate, fixable): Fix it, re-run that gate, continue.
Major issue (multiple gates, design problem): Stop and report. When changing approach, log it in the initiative's scratch notes:
Append to .sage/work/[initiative]/scratch.md:
approach-[N]: [what was tried] — [why it failed]
If scratch.md has 3+ approaches for the same task, this is a
gotcha trigger — the sage-self-learning skill MUST store the finding
with WHEN/CHECK/BECAUSE format before continuing.
Sage: Task [N] failed quality gates: Gate 3: Security — SQL injection risk in [file] Gate 5: Verification — test_user_create fails
[1] Fix and continue [2] Discuss the approach
Sage: Task [N] has failed Gate [X] three times. The task spec may be ambiguous or contradictory.
Issue: [specific problem]
[1] Revise the task spec and retry [2] Skip this task and continue with others [3] Pause and discuss the approach
After every task (or every 3 tasks for long plans), show brief progress:
Sage: Task [N] complete. Continuing to Task [N+1] — [name]. Say "pause" to stop.
For tasks marked [P] (parallelizable), note: "Tasks [N] and [M] can run
in parallel. Running sequentially on this platform." (On Tier 1, dispatch both.)
After all tasks complete:
Present the result:
Sage: Implementation complete.
Feature: [name] Tests: [count] passing Commits: [count] Quality: All 5 gates passed on final review.
[A] Approve — merge/ship [R] Revise — needs changes [P] PR — create a pull request
🔒 MANDATORY CHECKPOINT: Wait for human decision.
Based on human's choice:
Update .sage/decisions.md if significant:
# Progress
Mode: idle
Feature: [YYYYMMDD-slug] (completed)
Phase: done
Next: "Tell me what to build next"
Updated: <timestamp>
| Situation | Action |
|-----------|--------|
| Implementation fails to compile | Run systematic-debug, fix, retry |
| Test can't be written (untestable design) | Flag to human, suggest interface simplification |
| Task is larger than expected | Report: "Task [N] is bigger than planned. Split into [A] and [B]?" |
| Discovered bug in existing code | Report: "Found unrelated bug in [X]. Note for later or fix now?" |
| Context window getting full | Commit current work, save state, suggest new session |
| All tasks done but integration broken | Create an "integration fix" task, add to plan, execute |
MUST (violation = lost work or broken trust):
SHOULD (violation = suboptimal experience):
MAY (context-dependent):
tools
Captures agent mistakes, corrections, and discovered gotchas so they are not repeated. Use when: (1) a command or operation fails unexpectedly, (2) the user corrects the agent, (3) the agent discovers non-obvious behavior through debugging, (4) an API or tool behaves differently than expected, (5) a better approach is found for a recurring task. Also searches past learnings before starting tasks to avoid known pitfalls. Activate alongside the sage-memory skill — they share the same MCP backend but serve different purposes (sage-memory = codebase knowledge, sage-self-learning = agent mistakes and gotchas).
development
Typed knowledge graph stored in sage-memory. Use when creating or querying structured entities (Person, Project, Task, Event, Document), linking related objects, checking dependencies, planning multi-step actions as graph transformations, or when skills need to share structured state. Trigger on "remember that X is Y", "what do I know about", "link X to Y", "show dependencies", "what blocks X", entity CRUD, cross-skill data access, or any request involving structured relationships between things.
tools
Integrates sage-memory into Sage workflows. Teaches the agent when to remember (store findings during work), when to recall (search memory at session start and task start), and how to learn (structured knowledge capture via sage learn). Use when the user mentions memory, remember, recall, learn, capture knowledge, onboard to codebase, or when starting any session where sage-memory MCP tools are available.
tools
Captures agent mistakes, corrections, and discovered gotchas so they are not repeated. Use when: (1) a command or operation fails unexpectedly, (2) the user corrects the agent, (3) the agent discovers non-obvious behavior through debugging, (4) an API or tool behaves differently than expected, (5) a better approach is found for a recurring task. Also searches past learnings before starting tasks to avoid known pitfalls. Activate alongside the sage-memory skill — they share the same MCP backend but serve different purposes (sage-memory = codebase knowledge, sage-self-learning = agent mistakes and gotchas).