/define -- Project Definition (Gates 0, WB, 1)
Single-session skill that produces codebase assessment (Gate 0), optional Working Backwards document (Gate WB), and an approved PRD (Gate 1). All three gates run as one continuous conversation -- the user does not leave between gates.
Rules
- Read fresh every time. Read
progress.txtfrom disk on every invocation -- never rely on conversation memory or cached values (STATE-03). - Single continuous session. Gates 0, WB, and 1 run in one conversation. The user does not leave between gates (DEF-14).
- Produce-then-review at every gate. Produce the full artifact, present it, offer Approve / Revise. Rejection = revision request (D-06, D-08).
- All checklist items must be resolved. Every review checklist item must be
[x]or[-](N/A with reason) before recording gate approval (DEF-06, D-07). - Write-ordering contract. When writing to state files, follow STATE-04
ordering. For
/define, onlyprogress.txtis modified (gate entries). - Interactive prompts. Use
AskUserQuestionfor all user-facing choices (2-4 options, max 12-character headers). - No auto-dispatch. Tell the user what to run next after completion. Never auto-invoke another skill.
Prerequisites
- Working directory is the project root (where
progress.txtlives or will be created by/project). progress.txtmust exist. If it does not, instruct the user to run/projectfirst to bootstrap project state.- Gate 0 must not already be approved (unless this is a revision mode invocation).
Step 1 -- Detect Mode and State
Read progress.txt from the project root. Find the line starting with
# Project-ID:, take the value after :, trim whitespace, and use it as <slug>.
Construct the artifact base path: .project/<slug>/. All artifact reads and writes
in this skill use this base path. If the header is missing, report the error and tell
the user to run /project to re-bootstrap.
Revision mode detection (DEF-15): Check ALL of the following:
prd.mdexists on disk- Gate 1 is already
[x]approved inprogress.txt - The user's message signals revision intent (keywords: "revise", "update PRD", "goals changed", "pivot", "change direction", "scope change")
If ALL true: jump to Step 6 (Revision Mode).
Greenfield detection (DEF-01, D-11): Check ALL of the following (all must be true to classify as greenfield):
- No
src/,app/, orlib/directories exist - No dependency manifests exist (
package.json,pyproject.toml,Cargo.toml,go.mod,requirements.txt,Gemfile,pom.xml,build.gradle) - Fewer than 5 non-config files
- Only boilerplate files (README, license, gitignore pattern)
If ALL true: record Gate 0 as [-] Gate 0: Codebase Alignment Skipped (greenfield)
in progress.txt. Skip to Step 4 (Gate WB Offer).
If ANY false: proceed to Step 2 (Gate 0).
Gate WB resume detection:
- If Gate WB is
[ ] Pendinginprogress.txt(from a previous session where the user deferred): proceed to Step 4 (Gate WB Offer) with re-prompt context. - If Gate 0 is not yet started
[ ]: proceed to Step 2 (Gate 0).
Already-approved detection:
- If Gate 0 is
[x]and Gate WB is[x]or[-]or[ ] Pending: proceed to Step 5 (Gate 1) or Step 4 if Gate WB is Pending. - If Gate 1 is
[x]and no revision intent: inform the user that Gate 1 is already complete. Ask if they want to revise (enters revision mode) or check status (run/project).
Step 2 -- Gate 0: Codebase Assessment
Read references/gate-0-codebase.md for the complete Gate 0 specification.
Follow the gate-0-codebase specification to:
- Spawn a sub-agent to scan the codebase (20-40 files).
- Synthesize findings into
.project/<slug>/docs/codebase-assessment.md. - Present findings and enter produce-then-review cycle.
- Generate review checklist (
.project/<slug>/docs/reviews/gate-0-review.md) usingreferences/review-checklist-template.md. - Validate checklist completeness before recording approval.
- Record Gate 0 approval in
progress.txtperreferences/progress-format.md.
Proceed to Step 3.
Step 3 -- Gate 0 Transition
Gate 0 is complete. Proceed to Step 4 (Gate WB Offer).
Step 4 -- Gate WB: Working Backwards (Optional)
Read references/gate-wb-working-backwards.md for the complete Gate WB specification.
Check current Gate WB state in progress.txt:
- If already
[x]or[-]: skip to Step 5 (Gate 1). - If
[ ] Pending: re-prompt the user for their decision. - If
[ ](not yet offered): offer Gate WB per the specification.
Follow the gate-wb specification to handle the 3-outcome offer:
- Yes: run WB interview, produce
.project/<slug>/docs/working-backwards.md, generate review checklist (.project/<slug>/docs/reviews/gate-wb-review.md), review cycle, record approval. - Skip: record
[-] Gate WB: Working Backwards Skippedinprogress.txt. Proceed to Step 5. - Defer: record
[ ] Gate WB: Working Backwards Pending -- offered, awaiting decisioninprogress.txt. Proceed to Step 5.
Gate WB Pending does NOT block Gate 1. The Pending state is tracked for /project
to remind the user later (D-09 overrides PROJ-07).
Proceed to Step 5.
Step 5 -- Gate 1: Scope Review
Read references/gate-1-prd.md for the complete Gate 1 specification.
Follow the gate-1 specification to:
- Silently re-read
.project/<slug>/docs/codebase-assessment.mdfrom disk for context (DEF-16). Do NOT recap or summarize it to the user -- use internally only. - Read
.project/<slug>/docs/working-backwards.mdif it exists (D-14 -- context only, does not auto-populate PRD sections). - Gather the initial project concept (seed the PRD).
- Conduct the 5-round interview (Scope, Inputs/Outputs, Security, Operational,
Milestone Scoping). One round at a time via
AskUserQuestion. - Produce
prd.mdusingassets/prd-template.md. - Present PRD for review (produce-then-review cycle: Approve / Revise / Partial Approve).
- Handle partial approval if needed (DEF-12 -- section checklist for focused revision of unchecked sections).
- Generate review checklist (
.project/<slug>/docs/reviews/gate-1-review.md) usingreferences/review-checklist-template.md. - Validate checklist completeness.
- Record Gate 1 approval in
progress.txt.
Proceed to Step 7 (Completion Report).
Step 6 -- Revision Mode
Read references/gate-1-prd.md for the revision mode specification.
Read existing prd.md from disk.
Re-read .project/<slug>/docs/codebase-assessment.md from disk if it exists (DEF-16
silent re-read -- no recap to user).
Follow the revision mode specification to:
- Ask "What changed?" -- focused interview on affected sections only.
- Revise
prd.mdwith edits. Show each change before and after. - Present for review (produce-then-review cycle).
- Generate or update review checklist (
.project/<slug>/docs/reviews/gate-1-review.md). - Surface downstream artifact impacts without auto-resetting (DD-6). List affected artifacts and ask the user which need re-review.
- Record Gate 1 re-approval with updated date in
progress.txt.
Proceed to Step 7.
Step 7 -- Completion Report
Display a summary of what was produced:
DEFINITION COMPLETE: [Project Title]
ARTIFACTS CREATED:
- .project/<slug>/docs/codebase-assessment.md (Gate 0) [or "Skipped (greenfield)"]
- .project/<slug>/docs/working-backwards.md (Gate WB) [or "Skipped" / "Pending"]
- prd.md (Gate 1)
REVIEW CHECKLISTS:
- .project/<slug>/docs/reviews/gate-0-review.md [if applicable]
- .project/<slug>/docs/reviews/gate-wb-review.md [if applicable]
- .project/<slug>/docs/reviews/gate-1-review.md
NEXT: Run /project to see updated status, then /design for Gate 2.
Error Handling
- Missing progress.txt: Do not proceed. Tell the user to run
/projectfirst to bootstrap project state. - Gate 0 already approved: Skip Gate 0 (it was already done in a previous
session). Proceed from the appropriate gate based on
progress.txtstate. - Gate 1 already approved without revision intent: Inform the user that Gate 1
is already complete. Use
AskUserQuestionwith options: Revise (enters revision mode) or Status (suggests running/project). - Missing Project-ID header: If
progress.txtexists but has no# Project-ID:line, do not proceed. Tell the user to run/projectto re-bootstrap and add the Project-ID header. - Interrupted session: If the conversation is interrupted mid-gate, the user
can re-invoke
/define. The skill re-readsprogress.txtand resumes from the appropriate gate based on which gates are already approved. - Agent scan failure: If the codebase scan agent fails or returns empty results, report the failure to the user and offer to proceed with a manual assessment (user describes the codebase) or retry.