sub-project
Creates an isolated sub-project workspace within a parent project to keep Claude's context focused and high-quality. Invoke with /sub-project.
Sub-Project
Partitions a parent project into a focused sub-workspace so Claude operates within a lean, high-quality context instead of degrading across a bloated one. Quality at 100K tokens is fundamentally different from quality at 500K — this skill exists to keep every session in the high-accuracy zone.
Context-window strategy: Non-interactive phases delegate to subagents.
The discovery interview (Phase 2) stays inline. Each subagent reads its own
instructions from agents/ — never load reference files into main context
unless explicitly needed.
Inputs
| Input | Source | Required |
|---|---|---|
| Sub-project name | User prompt | Yes |
| Sub-project path | User prompt or <parent>/<name>/ | Yes |
| Task description | User prompt | Yes |
| Parent project root | cwd or user prompt | Yes |
--worktree | Flag | No (opt-in git isolation) |
--no-interview | Flag | No (skip Phase 2 discovery) |
Outputs
- Sub-project directory with tailored project docs
architecture.md— distilled parent context + sub-project specificsbuild-plan.md— sub-project-specific implementation planfeatures.md— sub-project feature set- CLAUDE.md or
rules/config (mirrors parent pattern) - Symlinked shared config (coterie.md, linting, etc.)
cnotes.md— fresh collaboration logtodo.md— fresh task tracker
Instructions
Phase 0: Detect Parent Pattern
Before anything else, detect how the parent project configures Claude:
- Check for
CLAUDE.mdin parent root - Check for
.claude/rules/*.mdorrules/*.mdin parent root - Check for both
Store the result — the sub-project mirrors whichever pattern(s) the parent uses.
Check for existing sub-projects (directories with their own architecture.md
or CLAUDE.md inside the parent). If siblings exist, list them and warn about
potential conflicts with shared parent dependencies.
Pre-calculate relative symlink paths from the sub-project directory back to the parent root. Pass these as explicit values to the scaffolder — do not delegate path math to the subagent.
Also detect:
- Does
coterie.mdexist? (symlink target) - Does
project-context.mdexist? (distillation source) - Does
project-plan.mdexist? (scope reference) - Does
features.mdexist? (feature reference) - Does
architecture.mdexist? (architecture reference) - What's in
.gitignore? (inherit relevant patterns)
Phase 1: Analyze Parent Project [Subagent]
Dispatch a Sonnet subagent to analyze the parent project. Read
agents/analyzer.md for the prompt template — fill in placeholders before
spawning.
The analyzer extracts:
- Dependency graph (imports, exports, module boundaries)
- Tech stack and framework versions
- API surface of modules relevant to the sub-project task
- Type definitions and shared interfaces
- Build/test/lint commands
- Coding conventions (from linting config, existing code patterns)
- Cross-cutting concerns (auth, logging, DB, design tokens)
The analyzer writes its findings to a temp file. Read the output when complete.
Exit condition: Analyzer output exists with dependency graph, API surface, and conventions extracted.
Phase 2: Discovery Interview [Inline]
Show the analyzer's findings to the user, then ask up to 3 targeted questions to fill gaps automation cannot:
-
What is the primary deliverable and merge-back timeline? (Intent and constraints not inferrable from code)
-
What must NOT be modified in the parent project? (Tribal knowledge — frozen APIs, shared state, protected paths)
-
What conventions apply locally but aren't enforced in code? (Naming patterns, architectural decisions, team norms)
Skip questions the analyzer already answered. If the analyzer covered everything, skip the interview entirely and confirm with the user:
"Automated analysis looks complete. Anything to add before I scaffold?"
Exit condition: User confirms the scope is clear.
Phase 3: Scaffold Sub-Project [Subagent]
Dispatch a Sonnet subagent to create the sub-project directory structure.
Read agents/scaffolder.md for the prompt template.
The scaffolder creates:
<sub-project>/
artifacts/
research/
summary/
reviews/
compact/
references/
CLAUDE.md (or rules/, or both — mirrors parent)
coterie.md -> ../../coterie.md (symlink)
.gitignore (inherited + sub-project additions)
cnotes.md (fresh from template)
todo.md (fresh from template)
Symlinked files (always current, single source of truth):
coterie.md— collaboration rules are project-wide- Linting configs (
.eslintrc,.prettierrc, etc.) if they exist .editorconfigif it exists- Design token files if they exist
Generated fresh (tailored to sub-project scope):
architecture.md— Phase 4 handles thisbuild-plan.md— Phase 5 handles thisfeatures.md— Phase 5 handles thisproject-context.md— lightweight, sub-project scopedCLAUDE.md/rules/— references sub-project docs, not parentcnotes.md— empty templatetodo.md— empty template
Exit condition: Directory structure exists. Symlinks verified. Fresh files created with template content.
Phase 4: Distill Architecture [Subagent]
This is the critical phase. Dispatch an Opus subagent to generate
architecture.md. Read agents/distiller.md for the prompt template.
The distiller receives:
- Analyzer output from Phase 1
- User answers from Phase 2
- Parent's
project-context.md,architecture.md, andproject-plan.md
It produces architecture.md with these 11 sections:
- Project Overview — 1 paragraph: what this sub-project builds and why
- Tech Stack — languages, frameworks, versions (from parent)
- Architecture — relevant components and their relationships
- Directory Structure — annotated tree of the sub-project
- API Surface — interfaces, types, exported contracts from parent that this sub-project consumes or produces
- Cross-Cutting Concerns — auth, logging, DB schema, design tokens — only what's relevant to this sub-project's scope
- Coding Conventions — style rules with code examples (from parent). Includes a Testing subsection: test file structure, runner, mocking patterns, coverage expectations
- Commands — build, test, lint with full flags (adapted for sub-project)
- Known Constraints — performance, security, compatibility requirements
- Parent Dependencies — explicit list of what this sub-project imports from the parent, with file paths and version constraints
- Parent Modifications — explicit list of parent files this sub-project will modify (migrations, shared types, API endpoints), with the nature of each change. Empty if sub-project is purely additive
Design principle: This file must contain almost everything Claude needs to complete the sub-project build. Minimize trips back to the parent project. Think of it as a "context distillation" — 70-98% compression of the parent while preserving all information relevant to this scope.
Exit condition: architecture.md exists with all 11 sections populated.
No placeholders, no "TBD", no "see parent project."
Phase 5: Generate Project Docs [Subagent]
Dispatch a Sonnet subagent to generate the remaining project docs. Read
agents/doc-generator.md for the prompt template.
Generate:
build-plan.md— Sub-project specific. Phases, milestones, work units sized for the sub-project scope. Follow the same format as the parent'sproject-plan.mdbut scoped to this deliverable only.features.md— Sub-project feature set. What this sub-project delivers, acceptance criteria, status tracking.project-context.md— Lightweight context doc. Scope, constraints, decisions specific to this sub-project. Referencesarchitecture.mdfor technical details rather than duplicating.- CLAUDE.md (or rules/) — References sub-project docs. Points to
architecture.md,build-plan.md,features.md,coterie.md.
Exit condition: All docs exist, internally consistent, no references to missing files.
Phase 6: Transfer Research [Inline]
Check the parent's artifacts/research/ for relevant prior research.
- List all research summaries in
artifacts/research/summary/ - For each, read the title and executive summary
- Present relevant ones to the user:
"Found {N} research summaries. These look relevant to the sub-project:
- 003D: Authentication patterns for microservices
- 005: WebSocket scaling strategies Copy these to the sub-project? (y/n/pick)"
- Copy selected summaries to
<sub-project>/artifacts/research/summary/
Exit condition: Relevant research transferred (or none if not applicable).
Phase 7: Worktree Setup [Inline, Opt-In]
If the user passed --worktree or requests git isolation:
- Create a git branch:
sub/<sub-project-name> - Create a worktree:
git worktree add <sub-project-path> sub/<sub-project-name> - Verify the worktree is functional
If not requested, the sub-project lives as a subdirectory in the main worktree. Present the option:
"Sub-project is ready as a subdirectory. Want git isolation via worktree? (Recommended for parallel development or risky refactors)"
Exit condition: Worktree created if requested, or user confirmed subdirectory mode.
Phase 8: Validation & Presentation [Inline]
Final checks:
- All symlinks resolve correctly
- All generated docs exist and have content
architecture.mdhas all 11 sectionsbuild-plan.mdhas work units with acceptance criteria- No broken file references in CLAUDE.md / rules/
- Sub-project can be
cd'd into and Claude would have full context
Present the summary:
"Sub-project
{name}is ready at{path}.Symlinked (stays current): coterie.md, [linting configs] Generated (sub-project specific): architecture.md, build-plan.md, features.md, project-context.md, CLAUDE.md Research transferred: [list or "none"] Git isolation: worktree on
sub/{name}/ subdirectory modeNext steps:
cd {path}and start building- Run
/meta-executeto implement the build plan- Run
/meta-reviewto review the sub-project docs first"
Error Handling
- If parent has no
project-context.md, warn and proceed — the analyzer and interview must compensate. - If parent has no
architecture.md, the distiller works from analyzer output andproject-context.mdalone. - If symlink creation fails (Windows, permissions), fall back to copy with a warning: "Symlink failed — copied instead. This copy will NOT auto-update."
- If the analyzer subagent fails, fall back to the interview for all context gathering. Skip Phase 1 findings presentation.
Merge-Back Guidance
When the sub-project is complete and ready to merge back:
- Run integration tests from the parent root
- Check for convention drift (run
/compliance-reviewfrom parent) - Update parent's
project-plan.mdto reflect completed work - Remove worktree if used:
git worktree remove <path> - Clean up the sub-project branch if merged
This guidance is documented in the sub-project's architecture.md under
"Known Constraints" so future sessions have it.
Examples
User: "/sub-project auth-service — build the authentication microservice"
Action: Detect parent pattern. Analyze parent for auth-related modules.
Interview for constraints. Scaffold auth-service/. Distill
architecture.md with auth focus. Generate build-plan. Present.
User: "/sub-project frontend-redesign --worktree"
Action: Full flow with git worktree isolation. Branch sub/frontend-redesign.
Distill architecture.md with frontend focus. Transfer relevant
UI research.
User: "I need to break out the payment processing into its own context"
Action: Detect trigger. Create sub-project for payment processing.
Heavy emphasis on API surface and cross-cutting concerns (auth,
logging, DB schema for transactions).
User: "/sub-project api-v2 — rewrite the REST API to GraphQL"
Action: Analyze existing REST endpoints. Distill architecture.md with
full API surface documentation. Generate build-plan for
migration work units. Transfer API-related research.
Before completing, read and follow ../references/cross-cutting-rules.md.