Implement

From xoai/sage · View interactive version

Implement is an AI agent skill from the GitHub repository xoai/sage. Implements a single task from the plan using TDD discipline. Reads the task spec, writes tests first, writes minimal passing code, refactors, and commits. Use when executing a planned task, writing code for a feature, or when the user says "implement this", "write the code", "build this task", or "e

How to use this skill

Skill file

<!-- sage-metadata

cost-tier: sonnet

activation: auto

tags: [implementation, coding, development]

inputs: [task-spec, plan, codebase-context, constitution]

outputs: [implementation, test-suite]

requires: [tdd, scope-guard]

-->

Implement

Write code for one task. Follow TDD. Stay in scope. Commit.

Core Principle: Implementation is the mechanical part. The thinking was done

in the spec and plan. Your job now is to faithfully translate the plan into working,

tested code — not to redesign, optimize, or "improve" beyond what was specified.

When to Use

During the execution phase of any workflow, when a task from the plan is ready

for implementation.

Process

Step 1: Read the Task Completely

Read the full task specification from the plan. Understand:

If anything is unclear, ASK before proceeding. Guessing at requirements

causes rework. It is always faster to ask one question than to rewrite

200 lines of code.

Step 2: Check Conventions

Reference the codebase-scan output and .sage/conventions.md:

Your implementation MUST follow existing conventions unless the task

explicitly requires deviating from them.

Step 3: Implement Using TDD

Follow the tdd skill strictly:

  1. Write the test first. The test describes the behavior from the task spec.

Watch it fail. Verify it fails for the right reason.

  1. Write minimal code to pass. Only enough to make the test green.

Don't add error handling, edge cases, or optimizations not required by the task.

  1. Refactor if needed. Clean up duplication. Improve names. Keep tests green.
  2. Repeat for each behavior in the task.

Step 4: Self-Review Before Committing

Before declaring the task complete, check:

Step 5: Update Plan Progress

This is the critical persistence step. After committing, update the plan file

to record completion. This is NOT optional — it IS the state persistence mechanism.

In the plan file (.sage/work/<feature>/plan.md):

  1. Check the task's checkbox: - [ ] → - [x]
  2. Add the completion marker after the task name: ✅ DONE (commit: <hash>)
  3. Fill in the gate results in the Gate Log table (after gates run)
  4. Update the plan's **Last updated:** timestamp
  5. If this was the last task, update **Status:** to complete

Why this matters: If the session ends unexpectedly — terminal closed, context

window full, connection dropped — the plan file on disk shows exactly which tasks

are done. The next session reads the plan file, sees the checkboxes, and resumes

from the right place. This works because artifacts are the source of truth.

Step 6: Commit

Write a semantic commit message:

<type>(<scope>): <short description>

<what was done and why, referencing the task>

Types: feat, fix, refactor, test, docs, chore

Rules

MUST (violation = broken code or lost work):

Each task = one commit (or a small sequence of commits).

SHOULD (violation = suboptimal but working):

spend 30 minutes on a "5-minute task" without communicating.

MAY (context-dependent):

Subagent Mode

On Tier 1 platforms (Claude Code, Codex), each task implementation MAY be

dispatched to a fresh subagent with clean context. The subagent receives:

The subagent implements, tests, self-reviews, and commits. Then the spec-review

and quality-review run as separate subagents (adversarial review).

On Tier 2 platforms, the same process runs sequentially in one session.

Failure Modes

splitting it into [A] and [B]. Approve?"

interface. Use dependency injection. If the framework makes testing impossible,

flag it and discuss.

"Found a bug in [X]: [description]. Should I fix it now (adds scope) or note

it for later?" If approved, create a separate task and commit.

missing dependencies with hacks.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.