Initialize Blueprint Development in this project.
When to Use This Skill
| Use this skill when... |
Use blueprint-upgrade instead when... |
The project has no docs/blueprint/manifest.json yet |
The project already has a manifest at an older format version |
| You're bootstrapping a new project's PRD/ADR/PRP directories |
You're migrating v1.x→v2, v2→v3, or v3.x→v3.y |
| You want to enable feature tracking and decision detection from scratch |
Use blueprint-derive-plans to populate PRDs/ADRs/PRPs after init |
| You're configuring task scheduling for the first time |
Use blueprint-execute instead when you want auto-detection of next step |
Steps
- Check if already initialized:
1a. Detect monorepo context (format_version 3.3.0+):
- Walk upward from the current directory looking for an ancestor
docs/blueprint/manifest.json (stop at the repo root or $HOME).
- If an ancestor root manifest exists, this init is creating a child
workspace. Capture the relative path from the child back to the root.
- Additionally scan descendants (max depth 4, skipping
node_modules,
.git, dist, build, target, .venv) for existing
docs/blueprint/manifest.json. If any are found, this init is creating a
root that will own existing children.
- Otherwise this is a standalone blueprint (no
workspaces block written).
Use AskUserQuestion (only when ancestor root detected):
question: "Found a parent blueprint at {parent_path}. Register this as a child workspace?"
options:
- label: "Yes - register as child"
description: "Writes workspaces.role=child + root_relative_path; root picks it up on next /blueprint:workspace-scan"
- label: "No - treat as standalone"
description: "No workspaces block written; this project is independent"
Ask about feature tracking (use AskUserQuestion):
question: "Would you like to enable feature tracking?"
options:
- label: "Yes - Track implementation against requirements"
description: "Creates feature-tracker.json to track FR codes from a requirements document"
- label: "No - Skip feature tracking"
description: "Can be added later with /blueprint:feature-tracker-sync"
If "Yes" selected:
a. Search for markdown files in the project that contain requirements, features, or user stories
b. Auto-detect the most likely source document based on content analysis
c. Create docs/blueprint/feature-tracker.json from template using the detected source
d. Set has_feature_tracker: true in manifest
Ask about document migration (use AskUserQuestion):
Search for existing markdown documentation files across the project (excluding standard files like README.md, CHANGELOG.md, CONTRIBUTING.md, LICENSE.md, CODE_OF_CONDUCT.md, SECURITY.md).
# Find markdown files that look like documentation (not standard repo files)
find . -name '*.md' -not -path '*/node_modules/*' -not -path '*/.git/*' | grep -viE '(README|CHANGELOG|CONTRIBUTING|LICENSE|CODE_OF_CONDUCT|SECURITY)\.md$'
Before recommending migration, measure cross-reference density. Migrating
a doc into docs/{prds,adrs,prps}/ rewrites its path, breaking every
reference to it. For each candidate doc, grep the repo for references to its
path from outside docs/ (README, scripts, CI, .rulesync/) and inter-doc
links:
# Count references to each candidate doc path (skip the doc itself)
for doc in $candidate_docs; do
base=$(basename "$doc")
refs=$(grep -rIl --exclude-dir=.git --exclude-dir=node_modules "$base" . | grep -v "^./$doc$" | wc -l | tr -d ' ')
ext=$(grep -rIl --exclude-dir=.git --exclude-dir=node_modules --exclude-dir=docs "$base" . | wc -l | tr -d ' ')
echo "$doc total=$refs outside_docs=$ext"
done
A doc whose path is referenced outside docs/ (build scripts, CI, README,
.rulesync/) is expensive to migrate — every reference must be rewritten,
including build-critical files. Blueprint only needs the empty
docs/{prds,adrs,prps}/ for future derived docs, so "leave in place" is a
safe default when migration is expensive.
If documentation files found (e.g., REQUIREMENTS.md, ARCHITECTURE.md, DESIGN.md, docs in non-standard locations):
- Default to recommending migration (
label: "Yes, migrate documents (Recommended)") only when no candidate doc is referenced outside docs/.
- When one or more candidate docs are referenced outside
docs/, DROP the "(Recommended)" marker from the migrate option and surface the reference count so the user judges the cost. Prefer steering toward "leave in place".
Use AskUserQuestion:
question: "Found existing documentation: {file_list}. {N} of these are referenced outside docs/ ({ref_summary}). Migrate to Blueprint-managed paths?"
options:
# When NO candidate is referenced outside docs/: keep "(Recommended)" on migrate.
# When ANY candidate IS referenced outside docs/: drop "(Recommended)" and show counts.
- label: "Yes, migrate documents"
description: "Move docs into docs/prds/, docs/adrs/, docs/prps/ based on content type. Rewrites all {total_refs} references — including build-critical files when referenced outside docs/."
- label: "No, leave them in place"
description: "Blueprint creates new docs under docs/{prds,adrs,prps}/; existing docs stay where build tooling and READMEs already point. Safe default when docs are referenced outside docs/."
If "Yes" selected:
a. Analyze each file to determine type:
- Contains requirements, features, user stories →
docs/prds/
- Contains architecture decisions, trade-offs →
docs/adrs/
- Contains implementation plans →
docs/prps/
- General documentation →
docs/
b. Move files to appropriate docs/ subdirectory
c. Rename to kebab-case if needed (REQUIREMENTS.md → requirements.md)
d. Report migration results:
Migrated documentation:
- REQUIREMENTS.md → docs/prds/requirements.md
- ARCHITECTURE.md → docs/adrs/0001-initial-architecture.md
If no documentation files found: Skip this step silently.
Ask about maintenance task scheduling (use AskUserQuestion):
question: "How should blueprint maintenance tasks run?"
options:
- label: "Prompt before running (Recommended)"
description: "Always ask before running maintenance tasks like sync, validate"
- label: "Auto-run safe tasks"
description: "Read-only tasks (validate, sync, status) run automatically when due"
- label: "Fully automatic"
description: "All tasks run automatically on schedule, including writes like rule generation"
- label: "Manual only"
description: "Tasks only run when you explicitly invoke them"
Store selection for task_registry defaults:
- Prompt: all
auto_run: false, default schedules
- Auto-run safe: read-only tasks (
adr-validate, feature-tracker-sync, sync-ids) get auto_run: true; write tasks get false
- Fully automatic: all tasks get
auto_run: true, default schedules
- Manual only: all
auto_run: false, all schedules set to on-demand
The same selection sets automation.autonomy_level (the ADR-0020 level
model — what actually executes the auto_run contract):
- Prompt / Manual only →
autonomy_level: 0 (nothing runs unattended)
- Auto-run safe →
autonomy_level: 1 (deterministic due tasks run via
the SessionStart probe; due agent tasks surface as drift findings)
- Fully automatic →
autonomy_level: 2 (quiet autopilot also runs due
agent tasks in-session; interaction_mode defaults to quiet)
4a. Ask about generated-rules output path (use AskUserQuestion):
Only prompt when .claude/rules/ already exists and contains files (i.e., hand-authored rules that pre-date blueprint). Skip silently in fresh repos and use the default.
# Only prompt if .claude/rules/ has any content not created by blueprint
find .claude/rules -maxdepth 1 -type f -name '*.md'
Use AskUserQuestion (only when .claude/rules/ has existing content):
question: "Detected existing content in .claude/rules/. Where should blueprint write generated rules?"
options:
- label: ".claude/rules/blueprint/ (Recommended)"
description: "Isolated subdirectory — keeps blueprint-managed and hand-authored rules separate, prevents collisions on regenerate"
- label: ".claude/rules/ (flat)"
description: "Write generated rules alongside hand-authored ones; risk of overwrite when filenames collide"
Store the chosen path in structure.generated_rules_path in the manifest (defaults to .claude/rules/ when unset). This keeps blueprint-generate-rules and blueprint-derive-rules from clobbering hand-curated rule files (issue #1043).
Ask about decision detection (use AskUserQuestion):
question: "Would you like to enable automatic decision detection?"
options:
- label: "Yes - Detect decisions worth documenting"
description: "Claude will notice when conversations contain architecture decisions, feature requirements, or implementation plans that should be captured as ADR/PRD/PRP documents"
- label: "No - Manual commands only"
description: "Use /blueprint:derive-plans, /blueprint:prp-create explicitly when you want to create documents"
Set has_document_detection in manifest based on response.
If enabled:
Resolve the rules output directory before writing — honour the path chosen in
Step 4a (default .claude/rules/) rather than hardcoding it, so blueprint
does not collide with rulesync-managed or hand-authored rules (issue #1675):
RULES_DIR=$(jq -r '.structure.generated_rules_path // ".claude/rules/"' docs/blueprint/manifest.json)
mkdir -p "$RULES_DIR"
When the manifest is not yet written, use the Step 4a selection directly
(default .claude/rules/).
Copy document-management-rule.md template to $RULES_DIR/document-management.md.
This rule instructs Claude to watch for:
- Architecture decisions being made during discussion → prompt to create ADR
- Feature requirements being discussed or refined → prompt to create/update PRD
- Implementation plans being formulated → prompt to create PRP
Create directory structure:
Canonical document paths are at the top level of docs/, not under docs/blueprint/. docs/blueprint/ holds blueprint machinery only (manifest, feature-tracker, work-orders); docs/{adrs,prds,prps,trps}/ hold the documents themselves. Every /blueprint:derive-* skill writes to the top-level paths — keeping them consistent prevents the dual-corpus bug where init creates one layout and derive-* writes to another.
Execute the creation explicitly so the directories exist even when no document migration happened in Step 3:
mkdir -p docs/blueprint/work-orders/completed
mkdir -p docs/blueprint/work-orders/archived
mkdir -p docs/adrs
mkdir -p docs/prds
mkdir -p docs/prps
Note: docs/trps/ is created on-demand by /blueprint:derive-tests only — init does not pre-create it.
The resulting tree:
docs/
├── blueprint/
│ ├── manifest.json # Version tracking and configuration
│ ├── feature-tracker.json # Progress tracking (if enabled)
│ ├── work-orders/ # Task packages for subagents
│ │ ├── completed/
│ │ └── archived/
│ └── README.md # Blueprint documentation
├── prds/ # Product Requirements Documents (canonical)
├── adrs/ # Architecture Decision Records (canonical)
├── prps/ # Product Requirement Prompts (canonical)
└── trps/ # Test Regression Plans (created on-demand by /blueprint:derive-tests)
Claude configuration (in .claude/): — initial rules are written under
structure.generated_rules_path (default .claude/rules/; an isolated
subdirectory like .claude/rules/blueprint/ when Step 4a detected existing
content), shown here at the default location:
.claude/
├── rules/ # $RULES_DIR — generated_rules_path (default .claude/rules/)
│ ├── development.md # Development workflow rules
│ ├── testing.md # Testing requirements
│ └── document-management.md # Document organization rules (if detection enabled)
└── skills/ # Custom skill overrides (optional)
Create manifest.json (v3.4.0 schema — canonical filename is docs/blueprint/manifest.json, no dot prefix):
{
"format_version": "3.4.0",
"created_at": "[ISO timestamp]",
"updated_at": "[ISO timestamp]",
"created_by": {
"blueprint_plugin": "3.3.0"
},
"project": {
"name": "[detected from package.json/pyproject.toml or directory name]",
"detected_stack": []
},
"structure": {
"has_prds": true,
"has_adrs": true,
"has_prps": true,
"has_work_orders": true,
"has_modular_rules": true,
"has_feature_tracker": "[based on user choice]",
"has_document_detection": "[based on user choice]",
"claude_md_mode": "both",
"generated_rules_path": "[based on Step 4a; defaults to .claude/rules/ when prompt skipped]"
},
"feature_tracker": {
"file": "feature-tracker.json",
"source_document": "[auto-detected]",
"sync_targets": ["TODO.md"]
},
"generated": {
"rules": {},
"commands": {}
},
"custom_overrides": {
"skills": [],
"commands": []
},
"automation": {
"autonomy_level": "[based on maintenance task choice: 0 for Prompt/Manual, 1 for Auto-run safe, 2 for Fully automatic]",
"interaction_mode": "normal",
"work_orders": {
"auto_draft": false,
"auto_execute": false
}
},
"task_registry": {
"derive-plans": {
"enabled": true,
"auto_run": false,
"last_completed_at": null,
"last_result": null,
"schedule": "weekly",
"stats": {},
"context": {}
},
"derive-rules": {
"enabled": true,
"auto_run": false,
"last_completed_at": null,
"last_result": null,
"schedule": "weekly",
"stats": {},
"context": {}
},
"generate-rules": {
"enabled": true,
"auto_run": false,
"last_completed_at": null,
"last_result": null,
"schedule": "on-change",
"stats": {},
"context": {}
},
"adr-validate": {
"enabled": true,
"auto_run": "[based on maintenance task choice: true if auto-run safe, false otherwise]",
"last_completed_at": null,
"last_result": null,
"schedule": "weekly",
"stats": {},
"context": {}
},
"feature-tracker-sync": {
"enabled": true,
"auto_run": "[based on maintenance task choice: true if auto-run safe, false otherwise]",
"last_completed_at": null,
"last_result": null,
"schedule": "daily",
"stats": {},
"context": {}
},
"sync-ids": {
"enabled": true,
"auto_run": "[based on maintenance task choice: true if auto-run safe, false otherwise]",
"last_completed_at": null,
"last_result": null,
"schedule": "on-change",
"stats": {},
"context": {}
},
"claude-md": {
"enabled": true,
"auto_run": false,
"last_completed_at": null,
"last_result": null,
"schedule": "on-change",
"stats": {},
"context": {}
},
"curate-docs": {
"enabled": false,
"auto_run": false,
"last_completed_at": null,
"last_result": null,
"schedule": "on-demand",
"stats": {},
"context": {}
}
}
}
Note: Include feature_tracker section only if feature tracking is enabled.
Note: As of v3.2.0, progress tracking is consolidated into feature-tracker.json (work-overview.md removed).
Monorepo workspaces block (v3.3.0+), appended to the manifest based on the
detection from Step 1a:
- Child (ancestor blueprint found and user opted in):
"workspaces": {
"role": "child",
"root_relative_path": "[relative path from this dir to the root]"
}
- Root (descendant blueprints found):
"workspaces": {
"role": "root",
"discovery_strategy": "auto-cache",
"last_scanned_at": null,
"children": []
}
After writing the manifest, run /blueprint:workspace-scan once to
populate children[].
- Standalone: omit the
workspaces block entirely.
Create initial rules under the resolved $RULES_DIR (the Step 4a
generated_rules_path, default .claude/rules/) — never a hardcoded
.claude/rules/ — so they sit alongside, not on top of, rulesync-managed or
hand-authored rules (issue #1675):
RULES_DIR=$(jq -r '.structure.generated_rules_path // ".claude/rules/"' docs/blueprint/manifest.json)
mkdir -p "$RULES_DIR"
$RULES_DIR/development.md: TDD workflow, commit conventions
$RULES_DIR/testing.md: Test requirements, coverage expectations
$RULES_DIR/document-management.md: Document organization rules (if decision detection enabled)
8a. Register the rules just written in generated.rules — this step is not
optional. /blueprint:sync and the SessionStart drift probe detect staleness
by comparing a registered record's content_hash against the file on
disk, so a rule written here but never registered is invisible to both: a
local edit is undetectable, a revised template never propagates, and sync
reports clean over a set it cannot see. Nothing surfaces as an error
(issue #2331).
Register every rule Step 8 actually wrote — pass only the filenames that
exist (document-management.md only when decision detection was enabled in
Step 5):
bash "${CLAUDE_SKILL_DIR}/../../scripts/register-generated-rules.sh" \
--source "blueprint-init" \
--plugin-version "3.4.0" \
development.md testing.md document-management.md
The script is the same one /blueprint:generate-rules Step 5 uses, so the
two producers of $RULES_DIR cannot drift apart on the record shape or on
how the hash is computed. It resolves $RULES_DIR from
structure.generated_rules_path itself and writes, per rule, a
generatedRecord (source, generated_at, plugin_version,
content_hash, status) into the generated.rules object map defined by
blueprint-plugin/schemas/manifest.schema.json.
Key form — the manifest key is the rule's bare filename relative to
$RULES_DIR, including the .md extension (development.md, never
development and never .claude/rules/development.md). A consumer resolves
a rule as "$RULES_DIR/$key" and must not append .md. Check
REGISTERED= and STATUS=OK in the script's output before continuing.
Handle .gitignore:
- Always commit
CLAUDE.md and .claude/rules/ (shared project instructions)
- Add
docs/blueprint/work-orders/ to .gitignore (task-specific, may contain sensitive details)
- If secrets detected in
.claude/, warn user and suggest .gitignore entries
Report:
Blueprint Development initialized! (v3.3.0)
Blueprint structure created:
- docs/blueprint/manifest.json
- docs/blueprint/work-orders/
- docs/blueprint/README.md
[- docs/blueprint/feature-tracker.json (if feature tracking enabled)]
Project documentation (top-level — derive-* skills write here):
- docs/prds/ (Product Requirements Documents)
- docs/adrs/ (Architecture Decision Records)
- docs/prps/ (Product Requirement Prompts)
- docs/trps/ (Test Regression Plans — created on first /blueprint:derive-tests run)
Claude configuration:
- .claude/rules/ (modular rules, including generated)
- .claude/skills/ (custom skill overrides)
Configuration:
- Rules mode: both (CLAUDE.md + .claude/rules/)
[- Feature tracking: enabled]
[- Decision detection: enabled (Claude will prompt when discussions should become ADR/PRD/PRP)]
[- Task scheduling: {prompt|auto-run safe|fully automatic|manual only}]
[Migrated documentation:]
[- {original} → {destination} (for each migrated file)]
Architecture:
- Plugin layer: Generic commands from blueprint-plugin (auto-updated)
- Generated layer: Rules/commands regeneratable from docs/prds/
- Custom layer: Your overrides in .claude/skills/
Prompt for next action (use AskUserQuestion):
question: "Blueprint initialized. What would you like to do next?"
options:
- label: "Derive plans from git history (Recommended)"
description: "Analyze commit history, PRs, and issues to build PRDs, ADRs, and PRPs from existing project decisions"
- label: "Derive rules from codebase"
description: "Analyze commit patterns and code conventions to generate .claude/rules/"
- label: "Update CLAUDE.md"
description: "Generate or update CLAUDE.md with project context and blueprint integration"
- label: "I'm done for now"
description: "Exit - you can run /blueprint:status anytime to see options"
Based on selection:
- "Derive plans from git history" → Run
/blueprint:derive-plans
- "Derive rules from codebase" → Run
/blueprint:derive-rules
- "Update CLAUDE.md" → Run
/blueprint:claude-md
- "I'm done for now" → Show quick reference and exit
Quick Reference (show if user selects "I'm done for now"):
Management commands:
- /blueprint:status - Check version and configuration
- /blueprint:upgrade - Upgrade to latest format version
- /blueprint:derive-plans - Derive PRDs, ADRs, and PRPs from git history
- /blueprint:derive-rules - Derive rules from git commit decisions
- /blueprint:prp-create - Create a Product Requirement Prompt
- /blueprint:generate-rules - Generate rules from PRDs
- /blueprint:sync - Check for stale generated content
- /blueprint:promote - Move generated content to custom layer
- /blueprint:rules - Manage modular rules
- /blueprint:claude-md - Update CLAUDE.md
- /blueprint:feature-tracker-status - View feature completion stats
- /blueprint:feature-tracker-sync - Sync tracker with project files
1---
2created: 2025-12-16
3modified: 2026-08-09
4reviewed: 2026-08-09
5description: Initialize Blueprint Development structure. Use when bootstrapping docs/blueprint/ with manifest, PRD/ADR/PRP directories, and feature tracking for the first time.
6allowed-tools: Bash, Write, Read, AskUserQuestion, Glob
7name: blueprint-init
8---
9
10Initialize Blueprint Development in this project.
11
12## When to Use This Skill
13
14| Use this skill when... | Use blueprint-upgrade instead when... |
15|---|---|
16| The project has no `docs/blueprint/manifest.json` yet | The project already has a manifest at an older format version |
17| You're bootstrapping a new project's PRD/ADR/PRP directories | You're migrating v1.x→v2, v2→v3, or v3.x→v3.y |
18| You want to enable feature tracking and decision detection from scratch | Use blueprint-derive-plans to populate PRDs/ADRs/PRPs after init |
19| You're configuring task scheduling for the first time | Use blueprint-execute instead when you want auto-detection of next step |
20
21## Steps
22
231. **Check if already initialized**:
24 - Look for `docs/blueprint/manifest.json`
25 - If exists, read version and ask user:
26 ```
27 Use AskUserQuestion:
28 question: "Blueprint already initialized (v{version}). What would you like to do?"
29 options:
30 - "Check for upgrades" → run /blueprint:upgrade
31 - "Reinitialize (will reset manifest)" → continue with step 2
32 - "Cancel" → exit
33 ```
34
351a. **Detect monorepo context** (format_version 3.3.0+):
36 - Walk upward from the current directory looking for an ancestor
37 `docs/blueprint/manifest.json` (stop at the repo root or `$HOME`).
38 - If an ancestor root manifest exists, this init is creating a **child**
39 workspace. Capture the relative path from the child back to the root.
40 - Additionally scan descendants (max depth 4, skipping `node_modules`,
41 `.git`, `dist`, `build`, `target`, `.venv`) for existing
42 `docs/blueprint/manifest.json`. If any are found, this init is creating a
43 **root** that will own existing children.
44 - Otherwise this is a **standalone** blueprint (no `workspaces` block written).
45
46 ```
47 Use AskUserQuestion (only when ancestor root detected):
48 question: "Found a parent blueprint at {parent_path}. Register this as a child workspace?"
49 options:
50 - label: "Yes - register as child"
51 description: "Writes workspaces.role=child + root_relative_path; root picks it up on next /blueprint:workspace-scan"
52 - label: "No - treat as standalone"
53 description: "No workspaces block written; this project is independent"
54 ```
55
562. **Ask about feature tracking** (use AskUserQuestion):
57 ```
58 question: "Would you like to enable feature tracking?"
59 options:
60 - label: "Yes - Track implementation against requirements"
61 description: "Creates feature-tracker.json to track FR codes from a requirements document"
62 - label: "No - Skip feature tracking"
63 description: "Can be added later with /blueprint:feature-tracker-sync"
64 ```
65
66 **If "Yes" selected:**
67 a. Search for markdown files in the project that contain requirements, features, or user stories
68 b. Auto-detect the most likely source document based on content analysis
69 c. Create `docs/blueprint/feature-tracker.json` from template using the detected source
70 d. Set `has_feature_tracker: true` in manifest
71
723. **Ask about document migration** (use AskUserQuestion):
73 Search for existing markdown documentation files across the project (excluding standard files like README.md, CHANGELOG.md, CONTRIBUTING.md, LICENSE.md, CODE_OF_CONDUCT.md, SECURITY.md).
74
75 ```bash
76 # Find markdown files that look like documentation (not standard repo files)
77 find . -name '*.md' -not -path '*/node_modules/*' -not -path '*/.git/*' | grep -viE '(README|CHANGELOG|CONTRIBUTING|LICENSE|CODE_OF_CONDUCT|SECURITY)\.md$'
78 ```
79
80 **Before recommending migration, measure cross-reference density.** Migrating
81 a doc into `docs/{prds,adrs,prps}/` rewrites its path, breaking every
82 reference to it. For each candidate doc, grep the repo for references to its
83 path **from outside `docs/`** (README, scripts, CI, `.rulesync/`) and inter-doc
84 links:
85
86 ```bash
87 # Count references to each candidate doc path (skip the doc itself)
88 for doc in $candidate_docs; do
89 base=$(basename "$doc")
90 refs=$(grep -rIl --exclude-dir=.git --exclude-dir=node_modules "$base" . | grep -v "^./$doc$" | wc -l | tr -d ' ')
91 ext=$(grep -rIl --exclude-dir=.git --exclude-dir=node_modules --exclude-dir=docs "$base" . | wc -l | tr -d ' ')
92 echo "$doc total=$refs outside_docs=$ext"
93 done
94 ```
95
96 A doc whose path is **referenced outside `docs/`** (build scripts, CI, README,
97 `.rulesync/`) is expensive to migrate — every reference must be rewritten,
98 including build-critical files. Blueprint only needs the **empty**
99 `docs/{prds,adrs,prps}/` for *future* derived docs, so "leave in place" is a
100 safe default when migration is expensive.
101
102 **If documentation files found** (e.g., REQUIREMENTS.md, ARCHITECTURE.md, DESIGN.md, docs in non-standard locations):
103
104 - **Default to recommending migration** (`label: "Yes, migrate documents (Recommended)"`) **only when no candidate doc is referenced outside `docs/`**.
105 - **When one or more candidate docs are referenced outside `docs/`**, DROP the "(Recommended)" marker from the migrate option and surface the reference count so the user judges the cost. Prefer steering toward "leave in place".
106
107 ```
108 Use AskUserQuestion:
109 question: "Found existing documentation: {file_list}. {N} of these are referenced outside docs/ ({ref_summary}). Migrate to Blueprint-managed paths?"
110 options:
111 # When NO candidate is referenced outside docs/: keep "(Recommended)" on migrate.
112 # When ANY candidate IS referenced outside docs/: drop "(Recommended)" and show counts.
113 - label: "Yes, migrate documents"
114 description: "Move docs into docs/prds/, docs/adrs/, docs/prps/ based on content type. Rewrites all {total_refs} references — including build-critical files when referenced outside docs/."
115 - label: "No, leave them in place"
116 description: "Blueprint creates new docs under docs/{prds,adrs,prps}/; existing docs stay where build tooling and READMEs already point. Safe default when docs are referenced outside docs/."
117 ```
118
119 **If "Yes" selected:**
120 a. Analyze each file to determine type:
121 - Contains requirements, features, user stories → `docs/prds/`
122 - Contains architecture decisions, trade-offs → `docs/adrs/`
123 - Contains implementation plans → `docs/prps/`
124 - General documentation → `docs/`
125 b. Move files to appropriate `docs/` subdirectory
126 c. Rename to kebab-case if needed (REQUIREMENTS.md → requirements.md)
127 d. Report migration results:
128 ```
129 Migrated documentation:
130 - REQUIREMENTS.md → docs/prds/requirements.md
131 - ARCHITECTURE.md → docs/adrs/0001-initial-architecture.md
132 ```
133
134 **If no documentation files found:** Skip this step silently.
135
1364. **Ask about maintenance task scheduling** (use AskUserQuestion):
137 ```
138 question: "How should blueprint maintenance tasks run?"
139 options:
140 - label: "Prompt before running (Recommended)"
141 description: "Always ask before running maintenance tasks like sync, validate"
142 - label: "Auto-run safe tasks"
143 description: "Read-only tasks (validate, sync, status) run automatically when due"
144 - label: "Fully automatic"
145 description: "All tasks run automatically on schedule, including writes like rule generation"
146 - label: "Manual only"
147 description: "Tasks only run when you explicitly invoke them"
148 ```
149
150 Store selection for task_registry defaults:
151 - **Prompt**: all `auto_run: false`, default schedules
152 - **Auto-run safe**: read-only tasks (`adr-validate`, `feature-tracker-sync`, `sync-ids`) get `auto_run: true`; write tasks get `false`
153 - **Fully automatic**: all tasks get `auto_run: true`, default schedules
154 - **Manual only**: all `auto_run: false`, all schedules set to `on-demand`
155
156 The same selection sets `automation.autonomy_level` (the ADR-0020 level
157 model — what actually *executes* the auto_run contract):
158 - **Prompt** / **Manual only** → `autonomy_level: 0` (nothing runs unattended)
159 - **Auto-run safe** → `autonomy_level: 1` (deterministic due tasks run via
160 the SessionStart probe; due agent tasks surface as drift findings)
161 - **Fully automatic** → `autonomy_level: 2` (quiet autopilot also runs due
162 agent tasks in-session; `interaction_mode` defaults to `quiet`)
163
1644a. **Ask about generated-rules output path** (use AskUserQuestion):
165
166 Only prompt when `.claude/rules/` already exists and contains files (i.e., hand-authored rules that pre-date blueprint). Skip silently in fresh repos and use the default.
167
168 ```bash
169 # Only prompt if .claude/rules/ has any content not created by blueprint
170 find .claude/rules -maxdepth 1 -type f -name '*.md'
171 ```
172
173 ```
174 Use AskUserQuestion (only when .claude/rules/ has existing content):
175 question: "Detected existing content in .claude/rules/. Where should blueprint write generated rules?"
176 options:
177 - label: ".claude/rules/blueprint/ (Recommended)"
178 description: "Isolated subdirectory — keeps blueprint-managed and hand-authored rules separate, prevents collisions on regenerate"
179 - label: ".claude/rules/ (flat)"
180 description: "Write generated rules alongside hand-authored ones; risk of overwrite when filenames collide"
181 ```
182
183 Store the chosen path in `structure.generated_rules_path` in the manifest (defaults to `.claude/rules/` when unset). This keeps `blueprint-generate-rules` and `blueprint-derive-rules` from clobbering hand-curated rule files (issue #1043).
184
1855. **Ask about decision detection** (use AskUserQuestion):
186 ```
187 question: "Would you like to enable automatic decision detection?"
188 options:
189 - label: "Yes - Detect decisions worth documenting"
190 description: "Claude will notice when conversations contain architecture decisions, feature requirements, or implementation plans that should be captured as ADR/PRD/PRP documents"
191 - label: "No - Manual commands only"
192 description: "Use /blueprint:derive-plans, /blueprint:prp-create explicitly when you want to create documents"
193 ```
194
195 Set `has_document_detection` in manifest based on response.
196
197 **If enabled:**
198 Resolve the rules output directory before writing — honour the path chosen in
199 Step 4a (default `.claude/rules/`) rather than hardcoding it, so blueprint
200 does not collide with rulesync-managed or hand-authored rules (issue #1675):
201
202 ```bash
203 RULES_DIR=$(jq -r '.structure.generated_rules_path // ".claude/rules/"' docs/blueprint/manifest.json)
204 mkdir -p "$RULES_DIR"
205 ```
206
207 When the manifest is not yet written, use the Step 4a selection directly
208 (default `.claude/rules/`).
209
210 Copy `document-management-rule.md` template to `$RULES_DIR/document-management.md`.
211 This rule instructs Claude to watch for:
212 - Architecture decisions being made during discussion → prompt to create ADR
213 - Feature requirements being discussed or refined → prompt to create/update PRD
214 - Implementation plans being formulated → prompt to create PRP
215
2166. **Create directory structure**:
217
218 **Canonical document paths** are at the **top level** of `docs/`, not under `docs/blueprint/`. `docs/blueprint/` holds blueprint machinery only (manifest, feature-tracker, work-orders); `docs/{adrs,prds,prps,trps}/` hold the documents themselves. Every `/blueprint:derive-*` skill writes to the top-level paths — keeping them consistent prevents the dual-corpus bug where init creates one layout and derive-* writes to another.
219
220 Execute the creation explicitly so the directories exist even when no document migration happened in Step 3:
221
222 ```bash
223 mkdir -p docs/blueprint/work-orders/completed
224 mkdir -p docs/blueprint/work-orders/archived
225 mkdir -p docs/adrs
226 mkdir -p docs/prds
227 mkdir -p docs/prps
228 ```
229
230 Note: `docs/trps/` is created on-demand by `/blueprint:derive-tests` only — init does not pre-create it.
231
232 The resulting tree:
233 ```
234 docs/
235 ├── blueprint/
236 │ ├── manifest.json # Version tracking and configuration
237 │ ├── feature-tracker.json # Progress tracking (if enabled)
238 │ ├── work-orders/ # Task packages for subagents
239 │ │ ├── completed/
240 │ │ └── archived/
241 │ └── README.md # Blueprint documentation
242 ├── prds/ # Product Requirements Documents (canonical)
243 ├── adrs/ # Architecture Decision Records (canonical)
244 ├── prps/ # Product Requirement Prompts (canonical)
245 └── trps/ # Test Regression Plans (created on-demand by /blueprint:derive-tests)
246 ```
247
248 **Claude configuration (in .claude/):** — initial rules are written under
249 `structure.generated_rules_path` (default `.claude/rules/`; an isolated
250 subdirectory like `.claude/rules/blueprint/` when Step 4a detected existing
251 content), shown here at the default location:
252 ```
253 .claude/
254 ├── rules/ # $RULES_DIR — generated_rules_path (default .claude/rules/)
255 │ ├── development.md # Development workflow rules
256 │ ├── testing.md # Testing requirements
257 │ └── document-management.md # Document organization rules (if detection enabled)
258 └── skills/ # Custom skill overrides (optional)
259 ```
260
2617. **Create `manifest.json`** (v3.4.0 schema — canonical filename is `docs/blueprint/manifest.json`, no dot prefix):
262 ```json
263 {
264 "format_version": "3.4.0",
265 "created_at": "[ISO timestamp]",
266 "updated_at": "[ISO timestamp]",
267 "created_by": {
268 "blueprint_plugin": "3.3.0"
269 },
270 "project": {
271 "name": "[detected from package.json/pyproject.toml or directory name]",
272 "detected_stack": []
273 },
274 "structure": {
275 "has_prds": true,
276 "has_adrs": true,
277 "has_prps": true,
278 "has_work_orders": true,
279 "has_modular_rules": true,
280 "has_feature_tracker": "[based on user choice]",
281 "has_document_detection": "[based on user choice]",
282 "claude_md_mode": "both",
283 "generated_rules_path": "[based on Step 4a; defaults to .claude/rules/ when prompt skipped]"
284 },
285 "feature_tracker": {
286 "file": "feature-tracker.json",
287 "source_document": "[auto-detected]",
288 "sync_targets": ["TODO.md"]
289 },
290 "generated": {
291 "rules": {},
292 "commands": {}
293 },
294 "custom_overrides": {
295 "skills": [],
296 "commands": []
297 },
298 "automation": {
299 "autonomy_level": "[based on maintenance task choice: 0 for Prompt/Manual, 1 for Auto-run safe, 2 for Fully automatic]",
300 "interaction_mode": "normal",
301 "work_orders": {
302 "auto_draft": false,
303 "auto_execute": false
304 }
305 },
306 "task_registry": {
307 "derive-plans": {
308 "enabled": true,
309 "auto_run": false,
310 "last_completed_at": null,
311 "last_result": null,
312 "schedule": "weekly",
313 "stats": {},
314 "context": {}
315 },
316 "derive-rules": {
317 "enabled": true,
318 "auto_run": false,
319 "last_completed_at": null,
320 "last_result": null,
321 "schedule": "weekly",
322 "stats": {},
323 "context": {}
324 },
325 "generate-rules": {
326 "enabled": true,
327 "auto_run": false,
328 "last_completed_at": null,
329 "last_result": null,
330 "schedule": "on-change",
331 "stats": {},
332 "context": {}
333 },
334 "adr-validate": {
335 "enabled": true,
336 "auto_run": "[based on maintenance task choice: true if auto-run safe, false otherwise]",
337 "last_completed_at": null,
338 "last_result": null,
339 "schedule": "weekly",
340 "stats": {},
341 "context": {}
342 },
343 "feature-tracker-sync": {
344 "enabled": true,
345 "auto_run": "[based on maintenance task choice: true if auto-run safe, false otherwise]",
346 "last_completed_at": null,
347 "last_result": null,
348 "schedule": "daily",
349 "stats": {},
350 "context": {}
351 },
352 "sync-ids": {
353 "enabled": true,
354 "auto_run": "[based on maintenance task choice: true if auto-run safe, false otherwise]",
355 "last_completed_at": null,
356 "last_result": null,
357 "schedule": "on-change",
358 "stats": {},
359 "context": {}
360 },
361 "claude-md": {
362 "enabled": true,
363 "auto_run": false,
364 "last_completed_at": null,
365 "last_result": null,
366 "schedule": "on-change",
367 "stats": {},
368 "context": {}
369 },
370 "curate-docs": {
371 "enabled": false,
372 "auto_run": false,
373 "last_completed_at": null,
374 "last_result": null,
375 "schedule": "on-demand",
376 "stats": {},
377 "context": {}
378 }
379 }
380 }
381 ```
382
383 Note: Include `feature_tracker` section only if feature tracking is enabled.
384 Note: As of v3.2.0, progress tracking is consolidated into feature-tracker.json (work-overview.md removed).
385
386 **Monorepo `workspaces` block (v3.3.0+)**, appended to the manifest based on the
387 detection from Step 1a:
388
389 - **Child** (ancestor blueprint found and user opted in):
390 ```json
391 "workspaces": {
392 "role": "child",
393 "root_relative_path": "[relative path from this dir to the root]"
394 }
395 ```
396 - **Root** (descendant blueprints found):
397 ```json
398 "workspaces": {
399 "role": "root",
400 "discovery_strategy": "auto-cache",
401 "last_scanned_at": null,
402 "children": []
403 }
404 ```
405 After writing the manifest, run `/blueprint:workspace-scan` once to
406 populate `children[]`.
407 - **Standalone**: omit the `workspaces` block entirely.
408
4098. **Create initial rules** under the resolved `$RULES_DIR` (the Step 4a
410 `generated_rules_path`, default `.claude/rules/`) — never a hardcoded
411 `.claude/rules/` — so they sit alongside, not on top of, rulesync-managed or
412 hand-authored rules (issue #1675):
413
414 ```bash
415 RULES_DIR=$(jq -r '.structure.generated_rules_path // ".claude/rules/"' docs/blueprint/manifest.json)
416 mkdir -p "$RULES_DIR"
417 ```
418
419 - `$RULES_DIR/development.md`: TDD workflow, commit conventions
420 - `$RULES_DIR/testing.md`: Test requirements, coverage expectations
421 - `$RULES_DIR/document-management.md`: Document organization rules (if decision detection enabled)
422
4238a. **Register the rules just written in `generated.rules`** — this step is not
424 optional. `/blueprint:sync` and the SessionStart drift probe detect staleness
425 by comparing a **registered** record's `content_hash` against the file on
426 disk, so a rule written here but never registered is invisible to both: a
427 local edit is undetectable, a revised template never propagates, and sync
428 reports clean over a set it cannot see. Nothing surfaces as an error
429 (issue #2331).
430
431 Register every rule Step 8 actually wrote — pass only the filenames that
432 exist (`document-management.md` only when decision detection was enabled in
433 Step 5):
434
435 ```bash
436 bash "${CLAUDE_SKILL_DIR}/../../scripts/register-generated-rules.sh" \
437 --source "blueprint-init" \
438 --plugin-version "3.4.0" \
439 development.md testing.md document-management.md
440 ```
441
442 The script is the same one `/blueprint:generate-rules` Step 5 uses, so the
443 two producers of `$RULES_DIR` cannot drift apart on the record shape or on
444 how the hash is computed. It resolves `$RULES_DIR` from
445 `structure.generated_rules_path` itself and writes, per rule, a
446 `generatedRecord` (`source`, `generated_at`, `plugin_version`,
447 `content_hash`, `status`) into the `generated.rules` **object map** defined by
448 `blueprint-plugin/schemas/manifest.schema.json`.
449
450 **Key form** — the manifest key is the rule's **bare filename relative to
451 `$RULES_DIR`, including the `.md` extension** (`development.md`, never
452 `development` and never `.claude/rules/development.md`). A consumer resolves
453 a rule as `"$RULES_DIR/$key"` and must **not** append `.md`. Check
454 `REGISTERED=` and `STATUS=OK` in the script's output before continuing.
455
4569. **Handle `.gitignore`**:
457 - Always commit `CLAUDE.md` and `.claude/rules/` (shared project instructions)
458 - Add `docs/blueprint/work-orders/` to `.gitignore` (task-specific, may contain sensitive details)
459 - If secrets detected in `.claude/`, warn user and suggest `.gitignore` entries
460
46110. **Report**:
462 ```
463 Blueprint Development initialized! (v3.3.0)
464
465 Blueprint structure created:
466 - docs/blueprint/manifest.json
467 - docs/blueprint/work-orders/
468 - docs/blueprint/README.md
469 [- docs/blueprint/feature-tracker.json (if feature tracking enabled)]
470
471 Project documentation (top-level — derive-* skills write here):
472 - docs/prds/ (Product Requirements Documents)
473 - docs/adrs/ (Architecture Decision Records)
474 - docs/prps/ (Product Requirement Prompts)
475 - docs/trps/ (Test Regression Plans — created on first /blueprint:derive-tests run)
476
477 Claude configuration:
478 - .claude/rules/ (modular rules, including generated)
479 - .claude/skills/ (custom skill overrides)
480
481 Configuration:
482 - Rules mode: both (CLAUDE.md + .claude/rules/)
483 [- Feature tracking: enabled]
484 [- Decision detection: enabled (Claude will prompt when discussions should become ADR/PRD/PRP)]
485 [- Task scheduling: {prompt|auto-run safe|fully automatic|manual only}]
486
487 [Migrated documentation:]
488 [- {original} → {destination} (for each migrated file)]
489
490 Architecture:
491 - Plugin layer: Generic commands from blueprint-plugin (auto-updated)
492 - Generated layer: Rules/commands regeneratable from docs/prds/
493 - Custom layer: Your overrides in .claude/skills/
494 ```
495
49611. **Prompt for next action** (use AskUserQuestion):
497 ```
498 question: "Blueprint initialized. What would you like to do next?"
499 options:
500 - label: "Derive plans from git history (Recommended)"
501 description: "Analyze commit history, PRs, and issues to build PRDs, ADRs, and PRPs from existing project decisions"
502 - label: "Derive rules from codebase"
503 description: "Analyze commit patterns and code conventions to generate .claude/rules/"
504 - label: "Update CLAUDE.md"
505 description: "Generate or update CLAUDE.md with project context and blueprint integration"
506 - label: "I'm done for now"
507 description: "Exit - you can run /blueprint:status anytime to see options"
508 ```
509
510 **Based on selection:**
511 - "Derive plans from git history" → Run `/blueprint:derive-plans`
512 - "Derive rules from codebase" → Run `/blueprint:derive-rules`
513 - "Update CLAUDE.md" → Run `/blueprint:claude-md`
514 - "I'm done for now" → Show quick reference and exit
515
516**Quick Reference** (show if user selects "I'm done for now"):
517```
518Management commands:
519- /blueprint:status - Check version and configuration
520- /blueprint:upgrade - Upgrade to latest format version
521- /blueprint:derive-plans - Derive PRDs, ADRs, and PRPs from git history
522- /blueprint:derive-rules - Derive rules from git commit decisions
523- /blueprint:prp-create - Create a Product Requirement Prompt
524- /blueprint:generate-rules - Generate rules from PRDs
525- /blueprint:sync - Check for stale generated content
526- /blueprint:promote - Move generated content to custom layer
527- /blueprint:rules - Manage modular rules
528- /blueprint:claude-md - Update CLAUDE.md
529- /blueprint:feature-tracker-status - View feature completion stats
530- /blueprint:feature-tracker-sync - Sync tracker with project files
531```