Plan

From xoai/sage · View interactive version

Plan is an AI agent skill from the GitHub repository xoai/sage. Creates implementation plans from specifications by breaking work into small tasks (2-5 min each) with exact file paths, tests, and dependency ordering. Use after a spec is approved and before implementation begins, or when the user says "create a plan", "break this down", "how should we build this"

How to use this skill

Skill file

<!-- sage-metadata

cost-tier: sonnet

activation: auto

tags: [planning, decomposition, tasks, implementation]

inputs: [spec, codebase-context, constitution]

outputs: [plan, tasks]

requires: []

-->

Plan

Turn a specification into an actionable implementation plan. This is where

technology decisions are made and work is broken into tasks small enough

for a single focused implementation session.

Core Principle: A plan should be clear enough for an enthusiastic junior

engineer with no project context, poor taste, no judgment, and an aversion to

testing to follow โ€” and still produce correct, well-tested code. If the plan

is ambiguous, the implementation will be wrong.

When to Use

After a spec is approved, before implementation begins.

Process

Step 1: Constitution Compliance Check

Before planning anything, verify the spec against the constitution:

apply to this feature?

dependencies) that constrain technology choices?

Document any constitution requirements that apply. These are non-negotiable

constraints on the plan.

Step 2: Technology Decisions (ARCHITECT mode only)

For BUILD mode, the tech stack already exists โ€” use what's there.

For ARCHITECT mode, make and document technology decisions:

Step 3: Task Decomposition

Read the spec's Deliverable field to determine task style.

PRD-Informed Planning

If the spec was produced from a PRD (the spec will reference the PRD and

include a component map and milestone structure):

  1. Read the milestone structure. The spec maps PRD requirements marked

"Delivers value independently: Yes" to milestone boundaries. Group

tasks into these milestones:

```markdown

## Milestone 1: [What's demoable after this group]

Delivers: R1, FR1, FR2 (foundational โ€” internal, verifiable)

๐Ÿ”’ CHECKPOINT: [What to verify. Can this be shipped independently?]

## Milestone 2: [What's demoable]

Delivers: R3, R5 (first user-visible value)

๐Ÿ”’ CHECKPOINT: [What to verify. Ship decision point.]

```

  1. Use the lean task template. Each task carries three fields beyond

the title โ€” enough context to execute independently without duplicating

content from the spec:

```markdown

```

The head is EXACTLY - [ ] **Task N:** title and Files:/Depends are

bullet-form โ€” this is machine-read grammar, not style: scope derive

and graph derive parse these lines at plan approval

(standard.plan-template.md carries the full grammar), and graph

derivation is fail-closed.

"Read first" is a pointer, not a copy. The agent loads the referenced

files at execution time. "Done" is derived from the PRD's acceptance

scenarios โ€” each scenario maps to at least one task's done criteria.

"Scope" prevents the agent from expanding work beyond the task boundary.

  1. Enforce no forward dependencies. Every task must be completable

based only on previous tasks. A task must never require a future task

to function. If task ordering creates a forward dependency, restructure.

  1. Size tasks for a single AI session. Each task should be completable

within one context window. If a task requires reading 15 files and

modifying 8 components, it's too large โ€” split it. This is guidance,

not a hard rule (some tasks are legitimately complex).

  1. Map PRD acceptance scenarios to tasks. Each Given/When/Then scenario

from the PRD should be covered by at least one task's "Done" criteria

or by an explicit integration test task. The final task in the plan

should verify all PRD scenarios pass as automated tests.

If the spec was NOT produced from a PRD (standard elicitation path), use

the existing task templates below.

Standard Task Templates

Break the work into tasks. Each task must be:

a short paragraph, it's too big โ€” split it.

to put it, what the result should look like.

dependencies โ€” each task depends only on previous tasks.

For code deliverables (or code tasks in mixed):
- [ ] **Task N:** [descriptive name]
  - **Read first:** [pack pattern files relevant to this task โ€” check .sage/skills/]
  - **Files:** [exact file paths to create or modify โ€” backticks welcome]
  - **Action:** [what to do โ€” be specific enough that there's no ambiguity]
  - **Test:** [what test to write, what it should verify]
  - **Verify:** [command to run to confirm task is complete]
  - **Depends on:** none | T<n>[, T<n>โ€ฆ]

The Read first field tells the agent which pack detail files to read before

starting the task. This ensures framework-specific guidance is loaded fresh at

the moment of decision โ€” not stale from earlier in the conversation. If the

project uses inline mode (all pack content in CLAUDE.md), this field can say

"(pack content already loaded)" instead of listing files.

For document deliverables (or document tasks in mixed):
- [ ] **Task N:** [descriptive name] [DOC]
  - **Read first:** [playbook reference files relevant to this section]
  - **Output:** [file path for the document, e.g. .sage/work/NNN/competitive-analysis.md]
  - **Action:** [what to write โ€” be specific about scope, structure, expected sections]
  - **Criteria:** [checklist of what "done" looks like for this section]
  - **Depends on:** none | T<n>[, T<n>โ€ฆ]

Document tasks use [DOC] marker. They have Criteria instead of Test

(a checklist reviewed against the spec's acceptance criteria, not a test command).

They have Output instead of Files (a single document path, not source code

files). Gates 04-06 (hallucination, verification, visual) skip for [DOC] tasks.

Gates 01-02 (spec compliance, constitution) always run.

For mixed deliverables:

The plan contains both code and document tasks. Each task is marked with its type.

Code tasks use the code template. Document tasks use the document template with

[DOC] marker. Gates apply per-task based on the marker.

Step 4: Identify Parallelism

Mark tasks that can run simultaneously (no dependency between them) with [P].

This enables parallel subagent execution on Tier 1 platforms.

- [ ] **Task 3:** Create user model [P]
  - **Depends on:** T1
- [ ] **Task 4:** Create auth middleware [P]
  - **Depends on:** T1
- [ ] **Task 5:** Integrate auth with user
  - **Depends on:** T3, T4

[P] goes AFTER the title, never inside the head โ€” **Task 3 [P]:**

is an unparseable head and refuses the whole derivation (fail-closed).

Step 4.5: Plan self-check (fresh eyes)

After the task list is complete and before presenting it, re-read the plan

against the spec as if seeing it for the first time. Run these three checks and

fix anything inline โ€” no re-review, just fix and move on. This is a self-run

check, not a sub-agent dispatch: independent review is auto-review's job at the

[A] checkpoint, and the two are complementary โ€” this pass catches mechanical

defects, auto-review catches judgment defects.

  1. Spec coverage. Walk each spec requirement (R1โ€ฆRn / FR1โ€ฆFRn). Can you point

to a task that implements it? List any requirement with no task and add the

missing task. A requirement with no task is the most expensive plan defect โ€”

it ships as a silent gap.

  1. Placeholder scan. Search the task bodies for red flags: TODO, TBD,

..., [fill in], "implement X here", or a Done-criterion that restates the

task name instead of a verifiable condition. Replace each with a concrete file

path, criterion, or code reference.

  1. Type / name consistency. Identifiers, function signatures, file paths, and

config keys referenced across tasks must match exactly. A function called

clearLayers() in one task and clearFullLayers() in another is a latent

bug. A file written as config.yaml in Task 2 and config.yml in Task 5 is

the same file โ€” reconcile to one spelling.

Record one line at the end of the plan: `Self-check: spec-coverage โœ“ ยท

placeholders โœ“ ยท consistency โœ“ (N fixes)`. If a check could not be completed

(e.g. the spec does not enumerate requirements), say so explicitly rather than

claiming โœ“.

Step 5: Output Plan

Save to .sage/work/<YYYYMMDD>-<slug>/plan.md using the plan template.

The plan uses checkbox format for built-in progress tracking:

# Implementation Plan: [feature name]

**Spec:** .sage/work/YYYYMMDD-slug/spec.md
**PRD:** .sage/work/YYYYMMDD-slug/brief.md (if applicable)
**Mode:** build
**Status:** not-started
**Started:**
**Last updated:**

## Constitution Constraints
[principles that apply, mandated patterns]

## Technology Decisions
[decision records for ARCHITECT mode, or "Using existing stack" for BUILD mode]

## Milestone 1: [What's demoable โ€” e.g., "Baseline computation (internal)"]

Delivers: [which PRD requirements, e.g., R1, FR1, FR2]

- [ ] **Task 1:** [name]
  - **Read first:** [spec sections, PRD scenarios, pack files]
  - **Files:** [repo-relative paths/globs]
  - **Done:** [1-2 line criteria]
  - **Depends on:** none

- [ ] **Task 2:** [name]
  - **Read first:** [files to load]
  - **Files:** [paths]
  - **Done:** [criteria]
  - **Depends on:** T1

๐Ÿ”’ CHECKPOINT: [What to verify. Ship decision if applicable.]

## Milestone 2: [What's demoable โ€” e.g., "Baseline in QLCT view (user value)"]

Delivers: [PRD requirements]

- [ ] **Task 3:** [name]
  - **Read first:** [files]
  - **Files:** [paths]
  - **Done:** [criteria]
  - **Depends on:** none

๐Ÿ”’ CHECKPOINT: [What to verify. Ship/demo decision.]

## Final: Integration verification

- [ ] **Task N:** End-to-end integration test
  - **Read first:** brief.md all acceptance scenarios
  - **Done:** All [count] PRD acceptance scenarios pass as automated tests
  - **Scope:** Tests only. No new code.

## Gate Log

| Task | Gate 1 | Gate 2 | Gate 3 | Gate 4 | Gate 5 |
|------|:---:|:---:|:---:|:---:|:---:|
| Task 1 | | | | | |
| Task 2 | | | | | |

Self-check: spec-coverage โœ“ ยท placeholders โœ“ ยท consistency โœ“ (N fixes)

For plans without a PRD source (standard elicitation), milestones are

optional โ€” use a flat task list if the feature is small enough.

The checkboxes ARE the progress tracker. When implement completes a task,

it checks the box (- [x]) and adds the commit hash. If the session dies, the

plan file shows exactly which tasks are done. No separate save action needed.

Artifact frontmatter tracks the plan location. No separate pointer needed.

# Progress

Mode: [build/architect]
Feature: [YYYYMMDD-slug]
Plan: .sage/work/YYYYMMDD-slug/plan.md
Phase: planning
Next: Human approval of plan, then implementation
Updated: [timestamp]

Show the plan to the human. Wait for approval before implementation begins.

Rules

MUST (violation = broken plan or wasted work):

tasks. If task 5 requires task 7, restructure the plan.

src/middleware/auth.ts, add validateExpiry() function" is good.

(when a PRD exists). If a scenario isn't covered, the plan is incomplete.

include its one-line Self-check: result in the output plan. This self-check

catches mechanical defects (a requirement with no task, a leftover placeholder,

an identifier that drifts between tasks); it is distinct from and complementary

to the independent auto-review that fires at the [A] checkpoint, which catches

judgment defects. The two are not redundant โ€” neither replaces the other.

SHOULD (violation = suboptimal but workable):

you're either in the wrong mode or the feature needs to be split.

flags exists. Milestones end at requirements that deliver user value

independently.

If a task requires loading more context than fits in one context window,

split it.

MAY (context-dependent):

Failure Modes

into multiple features, or switching to ARCHITECT mode.

as an earlier task.

means the task ordering is wrong. Move the depended-upon work earlier, or

restructure to eliminate the dependency.

to the spec and clarify.

to request a waiver or change the approach.

map to at least one task's done criteria, the plan has gaps. Add tasks or

expand existing task criteria to cover the missing scenario.

files or modifying too many components. Split into smaller tasks that each

fit within a single context window.

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.