agileflow 2.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/package.json +61 -0
  2. package/src/core/agents/accessibility.md +445 -0
  3. package/src/core/agents/adr-writer.md +215 -0
  4. package/src/core/agents/analytics.md +523 -0
  5. package/src/core/agents/api.md +484 -0
  6. package/src/core/agents/ci.md +452 -0
  7. package/src/core/agents/compliance.md +401 -0
  8. package/src/core/agents/context7.md +164 -0
  9. package/src/core/agents/database.md +377 -0
  10. package/src/core/agents/datamigration.md +565 -0
  11. package/src/core/agents/design.md +400 -0
  12. package/src/core/agents/devops.md +576 -0
  13. package/src/core/agents/documentation.md +229 -0
  14. package/src/core/agents/epic-planner.md +277 -0
  15. package/src/core/agents/integrations.md +459 -0
  16. package/src/core/agents/mentor.md +375 -0
  17. package/src/core/agents/mobile.md +391 -0
  18. package/src/core/agents/monitoring.md +430 -0
  19. package/src/core/agents/performance.md +390 -0
  20. package/src/core/agents/product.md +311 -0
  21. package/src/core/agents/qa.md +647 -0
  22. package/src/core/agents/readme-updater.md +325 -0
  23. package/src/core/agents/refactor.md +432 -0
  24. package/src/core/agents/research.md +250 -0
  25. package/src/core/agents/security.md +379 -0
  26. package/src/core/agents/testing.md +397 -0
  27. package/src/core/agents/ui.md +999 -0
  28. package/src/core/commands/adr.md +32 -0
  29. package/src/core/commands/agent.md +23 -0
  30. package/src/core/commands/assign.md +34 -0
  31. package/src/core/commands/auto.md +364 -0
  32. package/src/core/commands/babysit.md +1357 -0
  33. package/src/core/commands/baseline.md +520 -0
  34. package/src/core/commands/blockers.md +343 -0
  35. package/src/core/commands/board.md +241 -0
  36. package/src/core/commands/changelog.md +321 -0
  37. package/src/core/commands/ci.md +36 -0
  38. package/src/core/commands/compress.md +270 -0
  39. package/src/core/commands/context.md +222 -0
  40. package/src/core/commands/debt.md +268 -0
  41. package/src/core/commands/deploy.md +544 -0
  42. package/src/core/commands/deps.md +560 -0
  43. package/src/core/commands/diagnose.md +227 -0
  44. package/src/core/commands/docs.md +166 -0
  45. package/src/core/commands/epic.md +40 -0
  46. package/src/core/commands/feedback.md +307 -0
  47. package/src/core/commands/handoff.md +33 -0
  48. package/src/core/commands/help.md +90 -0
  49. package/src/core/commands/impact.md +204 -0
  50. package/src/core/commands/metrics.md +530 -0
  51. package/src/core/commands/packages.md +369 -0
  52. package/src/core/commands/pr.md +35 -0
  53. package/src/core/commands/readme-sync.md +168 -0
  54. package/src/core/commands/research.md +30 -0
  55. package/src/core/commands/resume.md +475 -0
  56. package/src/core/commands/retro.md +538 -0
  57. package/src/core/commands/review.md +364 -0
  58. package/src/core/commands/session-init.md +532 -0
  59. package/src/core/commands/setup.md +708 -0
  60. package/src/core/commands/sprint.md +490 -0
  61. package/src/core/commands/status.md +38 -0
  62. package/src/core/commands/story-validate.md +242 -0
  63. package/src/core/commands/story.md +38 -0
  64. package/src/core/commands/template.md +458 -0
  65. package/src/core/commands/tests.md +359 -0
  66. package/src/core/commands/update.md +407 -0
  67. package/src/core/commands/velocity.md +369 -0
  68. package/src/core/commands/verify.md +283 -0
  69. package/src/core/skills/acceptance-criteria-generator/SKILL.md +46 -0
  70. package/src/core/skills/adr-template/SKILL.md +62 -0
  71. package/src/core/skills/agileflow-acceptance-criteria/SKILL.md +156 -0
  72. package/src/core/skills/agileflow-adr/SKILL.md +147 -0
  73. package/src/core/skills/agileflow-adr/examples/database-choice-example.md +122 -0
  74. package/src/core/skills/agileflow-adr/templates/adr-template.md +69 -0
  75. package/src/core/skills/agileflow-commit-messages/SKILL.md +130 -0
  76. package/src/core/skills/agileflow-commit-messages/reference/bad-examples.md +168 -0
  77. package/src/core/skills/agileflow-commit-messages/reference/good-examples.md +120 -0
  78. package/src/core/skills/agileflow-commit-messages/scripts/check-attribution.sh +15 -0
  79. package/src/core/skills/agileflow-epic-planner/SKILL.md +184 -0
  80. package/src/core/skills/agileflow-retro-facilitator/SKILL.md +281 -0
  81. package/src/core/skills/agileflow-sprint-planner/SKILL.md +212 -0
  82. package/src/core/skills/agileflow-story-writer/SKILL.md +163 -0
  83. package/src/core/skills/agileflow-story-writer/examples/good-story-example.md +63 -0
  84. package/src/core/skills/agileflow-story-writer/templates/story-template.md +44 -0
  85. package/src/core/skills/agileflow-tech-debt/SKILL.md +215 -0
  86. package/src/core/skills/api-documentation-generator/SKILL.md +65 -0
  87. package/src/core/skills/changelog-entry/SKILL.md +55 -0
  88. package/src/core/skills/commit-message-formatter/SKILL.md +50 -0
  89. package/src/core/skills/deployment-guide-generator/SKILL.md +84 -0
  90. package/src/core/skills/diagram-generator/SKILL.md +65 -0
  91. package/src/core/skills/error-handler-template/SKILL.md +78 -0
  92. package/src/core/skills/migration-checklist/SKILL.md +82 -0
  93. package/src/core/skills/pr-description/SKILL.md +65 -0
  94. package/src/core/skills/sql-schema-generator/SKILL.md +69 -0
  95. package/src/core/skills/story-skeleton/SKILL.md +34 -0
  96. package/src/core/skills/test-case-generator/SKILL.md +63 -0
  97. package/src/core/skills/type-definitions/SKILL.md +65 -0
  98. package/src/core/skills/validation-schema-generator/SKILL.md +64 -0
  99. package/src/core/templates/README-template.md +16 -0
  100. package/src/core/templates/adr-template.md +28 -0
  101. package/src/core/templates/agent-profile-template.md +51 -0
  102. package/src/core/templates/agileflow-metadata.json +41 -0
  103. package/src/core/templates/ci-workflow.yml +74 -0
  104. package/src/core/templates/claude-settings.advanced.example.json +71 -0
  105. package/src/core/templates/claude-settings.example.json +26 -0
  106. package/src/core/templates/comms-note-template.md +24 -0
  107. package/src/core/templates/environment.json +18 -0
  108. package/src/core/templates/epic-template.md +27 -0
  109. package/src/core/templates/init.sh +76 -0
  110. package/src/core/templates/research-template.md +44 -0
  111. package/src/core/templates/resume-session.sh +121 -0
  112. package/src/core/templates/session-state.json +20 -0
  113. package/src/core/templates/skill-template.md +75 -0
  114. package/src/core/templates/story-template.md +88 -0
  115. package/src/core/templates/validate-tokens.sh +88 -0
  116. package/src/core/templates/worktree-create.sh +111 -0
  117. package/src/core/templates/worktrees-guide.md +235 -0
  118. package/tools/agileflow-npx.js +40 -0
  119. package/tools/cli/agileflow-cli.js +70 -0
  120. package/tools/cli/commands/doctor.js +243 -0
  121. package/tools/cli/commands/install.js +82 -0
  122. package/tools/cli/commands/status.js +121 -0
  123. package/tools/cli/commands/uninstall.js +110 -0
  124. package/tools/cli/commands/update.js +99 -0
  125. package/tools/cli/installers/core/installer.js +296 -0
  126. package/tools/cli/installers/ide/_base-ide.js +133 -0
  127. package/tools/cli/installers/ide/claude-code.js +174 -0
  128. package/tools/cli/installers/ide/cursor.js +189 -0
  129. package/tools/cli/installers/ide/manager.js +197 -0
  130. package/tools/cli/installers/ide/windsurf.js +192 -0
  131. package/tools/cli/lib/ui.js +203 -0
  132. package/tools/cli/lib/version-checker.js +95 -0
  133. package/tools/postinstall.js +141 -0
@@ -0,0 +1,708 @@
1
+ ---
2
+ description: Bootstrap entire AgileFlow system in current project
3
+ allowed-tools: Bash, Read, Edit, Write, Glob, Grep, TodoWrite
4
+ ---
5
+
6
+ # setup-system
7
+
8
+ Scaffold the universal agile/docs-as-code system for this repository.
9
+
10
+ ## Prompt
11
+
12
+ ROLE: System Scaffolder (Agile + Docs-as-Code)
13
+
14
+ OBJECTIVE
15
+ Create/update a universal agile/docs system that works in any repo. Be idempotent. Diff-first. Ask YES/NO before changing files or executing commands.
16
+
17
+ **CRITICAL FIRST STEP - CREATE TODO LIST**
18
+
19
+ Before doing anything else, use the TodoWrite tool to create a comprehensive task list. This prevents missing any configuration steps.
20
+
21
+ **Why TodoWrite is critical**:
22
+ - Claude has access to a TodoWrite tool that tracks tasks across the conversation
23
+ - Creating a todo list at the start ensures nothing is forgotten
24
+ - Each detection result should map to a todo item
25
+ - Mark items as in_progress → completed as you work
26
+
27
+ **Example todo list structure**:
28
+ ```json
29
+ [
30
+ {"content": "Detect current system status", "activeForm": "Detecting current system status", "status": "in_progress"},
31
+ {"content": "Initialize core AgileFlow structure", "activeForm": "Initializing core AgileFlow structure", "status": "pending"},
32
+ {"content": "Configure auto-archival system", "activeForm": "Configuring auto-archival system", "status": "pending"},
33
+ {"content": "Set up hooks system", "activeForm": "Setting up hooks system", "status": "pending"},
34
+ {"content": "Update CLAUDE.md with configuration", "activeForm": "Updating CLAUDE.md with configuration", "status": "pending"},
35
+ {"content": "Validate final setup", "activeForm": "Validating final setup", "status": "pending"}
36
+ ]
37
+ ```
38
+
39
+ **Workflow**:
40
+ 1. FIRST: Run detection phase (bash commands)
41
+ 2. SECOND: Based on detection, create TodoWrite list with ALL missing components
42
+ 3. THIRD: Ask user for preferences (one question at a time)
43
+ 4. FOURTH: Work through todo list, marking items completed as you go
44
+ 5. FINAL: Mark last todo as completed and display summary
45
+
46
+ DETECTION PHASE (run first, before asking anything)
47
+ Detect what's already configured and report status:
48
+
49
+ ```bash
50
+ # Check core structure
51
+ [ -d docs/00-meta ] && echo "✅ Core docs structure exists" || echo "❌ Core docs structure missing"
52
+ [ -f docs/09-agents/status.json ] && echo "✅ Agent status tracking exists" || echo "❌ Agent status tracking missing"
53
+
54
+ # Check CI
55
+ [ -f .github/workflows/ci.yml ] && echo "✅ CI workflow exists" || echo "❌ CI workflow missing"
56
+
57
+ # Check hooks system (v2.19.0+)
58
+ if [ -d .claude ] && [ -f .claude/settings.json ]; then
59
+ echo "✅ Hooks system configured"
60
+ else
61
+ echo "❌ Hooks system not configured"
62
+ fi
63
+
64
+ # Check auto-archival system (v2.19.4+)
65
+ if [ -f scripts/archive-completed-stories.sh ] && grep -q "archive-completed-stories.sh" .claude/settings.json 2>/dev/null; then
66
+ THRESHOLD=$(jq -r '.archival.threshold_days // "not configured"' docs/00-meta/agileflow-metadata.json 2>/dev/null)
67
+ echo "✅ Auto-archival configured (threshold: $THRESHOLD days)"
68
+ else
69
+ echo "❌ Auto-archival NOT configured (recommended for production)"
70
+ fi
71
+
72
+ # Check runtime detection
73
+ [ -f docs/00-meta/runtime.json ] && echo "✅ Runtime detected" || echo "❌ Runtime not detected"
74
+ ```
75
+
76
+ **Display Status Summary First**:
77
+ ```
78
+ 📊 Current AgileFlow Setup Status:
79
+ ==================================
80
+ Core System: ✅ Configured / ❌ Not configured
81
+ CI Workflow: ✅ Configured / ❌ Not configured
82
+ Hooks System: ✅ Configured / ❌ Not configured (v2.19.0+)
83
+ Auto-Archival: ✅ Configured (X days) / ❌ Not configured (v2.19.4+)
84
+ ```
85
+
86
+ INPUTS (ask only about missing/incomplete features)
87
+ Based on detection results above, ask ONLY about features that aren't fully configured:
88
+
89
+ - IF core system missing: "Initialize core AgileFlow structure? yes/no"
90
+
91
+ - **Git Attribution Preference** (ALWAYS ask on first setup):
92
+ - "Disable Claude Code attribution in git commits? (Removes '🤖 Generated with Claude Code' and 'Co-Authored-By: Claude' from commit messages) yes/no"
93
+ - **Why ask**: Many users prefer not to disclose AI usage in their git history due to:
94
+ - Professional reputation concerns
95
+ - Company policies against AI disclosure
96
+ - Client perception issues
97
+ - Personal preference for ownership
98
+ - **If yes**: Add to CLAUDE.md a CRITICAL section instructing Claude to NEVER add attribution
99
+ - **If no**: Claude will continue adding attribution as normal
100
+
101
+ - IF CI missing: "Create minimal CI workflow? yes/no"
102
+ - IF hooks not configured: "Set up hooks system? (event-driven automation) yes/no"
103
+
104
+ Skip asking about features that are already fully configured (just report them as ✅).
105
+
106
+ CREATE DIRECTORIES (if missing)
107
+
108
+ **CRITICAL: Use Validation Script (v2.22.2+)**
109
+
110
+ AgileFlow provides a validation script to ensure all required directories are created properly. This prevents issues where some folders may be missed during manual setup.
111
+
112
+ **Step 1: Copy validation script from plugin**:
113
+ ```bash
114
+ # Copy validation script from AgileFlow plugin to project
115
+ cp ~/.claude-code/plugins/AgileFlow/scripts/validate-setup.sh scripts/validate-setup.sh
116
+ chmod +x scripts/validate-setup.sh
117
+ ```
118
+
119
+ **Step 2: Run validation script**:
120
+ ```bash
121
+ bash scripts/validate-setup.sh
122
+ ```
123
+
124
+ **What the validation script does**:
125
+ - Checks for all required directories in docs/ structure
126
+ - Creates any missing directories automatically
127
+ - Reports status of critical files (status.json, agileflow-metadata.json)
128
+ - Provides a comprehensive validation summary
129
+
130
+ **Required directories** (all created by validation script):
131
+ - docs/{00-meta/{templates,guides,scripts},01-brainstorming/{ideas,sketches},02-practices/prompts/agents,03-decisions,04-architecture,05-epics,06-stories,07-testing/{acceptance,test-cases},08-project,09-agents/bus,10-research}
132
+ - .github/workflows
133
+ - .claude/
134
+ - scripts/
135
+
136
+ **Alternative: Manual directory creation** (if validation script not available):
137
+ ```bash
138
+ mkdir -p docs/{00-meta/{templates,guides,scripts},01-brainstorming/{ideas,sketches},02-practices/prompts/agents,03-decisions,04-architecture,05-epics,06-stories,07-testing/{acceptance,test-cases},08-project,09-agents/bus,10-research}
139
+ mkdir -p .github/workflows .claude scripts
140
+ ```
141
+
142
+ **IMPORTANT - docs/02-practices Purpose**:
143
+ - docs/02-practices is for **USER'S CODEBASE practices** (NOT AgileFlow system practices)
144
+ - Examples: Styling conventions, typography standards, CSS architecture, component patterns, API design patterns
145
+ - AgileFlow system documentation goes in docs/00-meta/ (guides, templates, scripts)
146
+ - This distinction ensures clarity between "how we build the product" vs "how we use AgileFlow"
147
+
148
+ CREATE/SEED FILES (only if missing; never overwrite non-empty content)
149
+ - docs/README.md — map of all folders
150
+ - docs/context.md — one-page brief with managed sections (placeholders)
151
+ - docs/00-meta/{glossary.md,conventions.md}
152
+ - docs/00-meta/agileflow-metadata.json — copy from templates/agileflow-metadata.json, update timestamp and version to CURRENT plugin version (read from ~/.claude-code/plugins/AgileFlow/.claude-plugin/plugin.json)
153
+ - docs/00-meta/templates/{README-template.md,story-template.md,epic-template.md,adr-template.md,agent-profile-template.md,comms-note-template.md,research-template.md}
154
+ - docs/00-meta/guides/worktrees.md — copy from templates/worktrees-guide.md (comprehensive git worktrees guide for context preservation)
155
+ - docs/02-practices/{README.md,testing.md,git-branching.md,releasing.md,security.md,ci.md} — **USER CODEBASE practices** (styling, typography, component patterns, API conventions, etc.) NOT AgileFlow practices
156
+ - docs/02-practices/prompts/agents/{agent-ui.md,agent-api.md,agent-ci.md} — Project-specific agent customization prompts
157
+ - docs/03-decisions/README.md
158
+ - docs/04-architecture/README.md
159
+ - docs/05-epics/README.md
160
+ - docs/06-stories/README.md
161
+ - docs/07-testing/README.md
162
+ - docs/08-project/{README.md,roadmap.md,backlog.md,milestones.md,risks.md}
163
+ - docs/09-agents/{README.md,status.json} // seed with {"updated":"","stories":{}}
164
+ - docs/09-agents/bus/log.jsonl // empty
165
+ - docs/10-research/README.md // index table: Date | Topic | Path | Summary
166
+ - .github/workflows/ci.yml // minimal, language-agnostic CI (lint/type/test placeholders)
167
+ - .gitignore // CRITICAL: MUST include .env (for secrets), plus generic: .env*, .DS_Store, .idea/, .vscode/, node_modules/, dist/, build/, coverage/
168
+ - .env.example // template file for environment variables
169
+ - docs/02-practices/prompts/commands-catalog.md // paste-ready list of all slash commands & prompts (print content at the end)
170
+ - **CLAUDE.md** — AI assistant configuration (create if missing, update if exists)
171
+
172
+ CLAUDE.MD GENERATION/UPDATE (CRITICAL)
173
+ **IMPORTANT**: CLAUDE.md is the AI assistant's primary configuration file. It MUST be created or updated based on user preferences.
174
+
175
+ **If CLAUDE.md does NOT exist**:
176
+ Create CLAUDE.md with:
177
+ 1. Project placeholder sections (Build/Test Commands, Architecture, etc.)
178
+
179
+ **If CLAUDE.md already exists**:
180
+ - Check if it contains git attribution rules
181
+ - If user chose to disable attribution AND CLAUDE.md doesn't have the rule → Add it
182
+ - If user chose to keep attribution AND CLAUDE.md has the disable rule → Remove it
183
+
184
+ **Print confirmation**:
185
+ ```
186
+ Git Attribution: [Disabled / Enabled]
187
+ - Commits will [NOT / WILL] include Claude Code attribution
188
+ - CLAUDE.md [updated / not modified] with attribution policy
189
+ ```
190
+
191
+ OS/RUNTIME DETECTION (safe, best-effort)
192
+ - Detect OS/arch and common runtimes using commands:
193
+ - Unix-like: `uname -s`, `uname -m`, `sh -c 'git --version || true'`
194
+ - Windows: `cmd /c ver` (or similar, best-effort)
195
+ - Save to docs/00-meta/runtime.json: { os, arch, git_version, detected_at }
196
+
197
+ GIT REPOSITORY SETUP (CRITICAL - required for all projects)
198
+ **IMPORTANT**: Every AgileFlow project should be a git repository with a configured remote. This enables version control, team collaboration, and backup.
199
+
200
+ **Detection**:
201
+ ```bash
202
+ # Check if git is initialized
203
+ [ -d .git ] && echo "✅ Git initialized" || echo "❌ Git not initialized"
204
+
205
+ # Check if remote is configured
206
+ git remote -v 2>/dev/null | grep -q origin && echo "✅ Git remote configured" || echo "⚠️ Git remote not configured"
207
+ ```
208
+
209
+ **Setup Steps**:
210
+
211
+ 1. **If git not initialized**:
212
+ - Ask user: "Initialize git repository? yes/no"
213
+ - If yes: `git init`
214
+
215
+ 2. **If remote not configured** (CRITICAL):
216
+ - Ask user: "Git remote URL (e.g., git@github.com:user/repo.git or https://github.com/user/repo.git):"
217
+ - Store in variable: `REPO_URL`
218
+ - Configure remote: `git remote add origin "$REPO_URL"`
219
+ - Verify: `git remote -v`
220
+ - Update agileflow-metadata.json:
221
+ ```json
222
+ {
223
+ "git": {
224
+ "initialized": true,
225
+ "remoteConfigured": true,
226
+ "remoteUrl": "git@github.com:user/repo.git"
227
+ }
228
+ }
229
+ ```
230
+
231
+ 3. **Print git setup status**:
232
+ ```
233
+ ✅ Git repository initialized
234
+ ✅ Git remote configured: git@github.com:user/repo.git
235
+
236
+ Next steps:
237
+ - Add files: git add .
238
+ - Create first commit: git commit -m "Initial commit with AgileFlow setup"
239
+ - Push to remote: git push -u origin main
240
+ ```
241
+
242
+ **Why This Matters**:
243
+ - Version control for all AgileFlow docs (epics, stories, ADRs)
244
+ - Team collaboration via GitHub/GitLab
245
+ - Backup and disaster recovery
246
+ - Enables proper .gitignore for secrets (.env)
247
+
248
+ HOOKS SYSTEM SETUP (v2.19.0+) - If Enabled
249
+ **IMPORTANT**: Hooks allow event-driven automation in Claude Code. When Claude Code lifecycle events occur (SessionStart, UserPromptSubmit, Stop), hooks automatically execute shell commands.
250
+
251
+ **What Are Hooks?**
252
+ - **SessionStart**: Runs when Claude Code session starts (welcome messages, context preloading)
253
+ - **UserPromptSubmit**: Runs after user submits a prompt (logging, analytics)
254
+ - **Stop**: Runs when Claude stops responding (cleanup, notifications)
255
+
256
+ **Step 1: Create .claude and scripts directories**:
257
+ ```bash
258
+ mkdir -p .claude scripts
259
+ ```
260
+
261
+ **Step 2: Copy get-env.js helper script**:
262
+ Copy from AgileFlow plugin's `scripts/get-env.js` to `scripts/get-env.js`:
263
+ ```javascript
264
+ #!/usr/bin/env node
265
+ /**
266
+ * get-env.js - Dynamic environment variable helper for hooks
267
+ * Usage: node scripts/get-env.js VARIABLE_NAME [default_value]
268
+ */
269
+ const fs = require('fs');
270
+ const path = require('path');
271
+
272
+ const varName = process.argv[2];
273
+ const defaultValue = process.argv[3] || '';
274
+
275
+ if (!varName) {
276
+ console.error('Usage: node scripts/get-env.js VARIABLE_NAME [default_value]');
277
+ process.exit(1);
278
+ }
279
+
280
+ const projectDir = process.cwd();
281
+ const claudePath = path.join(projectDir, '.claude');
282
+ let env = {};
283
+
284
+ // Read settings.json (base configuration)
285
+ try {
286
+ const settingsPath = path.join(claudePath, 'settings.json');
287
+ const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
288
+ if (settings.env) {
289
+ env = { ...env, ...settings.env };
290
+ }
291
+ } catch (e) {}
292
+
293
+ // Read settings.local.json (local overrides - gitignored)
294
+ try {
295
+ const localSettingsPath = path.join(claudePath, 'settings.local.json');
296
+ const localSettings = JSON.parse(fs.readFileSync(localSettingsPath, 'utf8'));
297
+ if (localSettings.env) {
298
+ env = { ...env, ...localSettings.env };
299
+ }
300
+ } catch (e) {}
301
+
302
+ const finalValue = env[varName] !== undefined ? env[varName] : defaultValue;
303
+ console.log(finalValue);
304
+ ```
305
+ Make executable: `chmod +x scripts/get-env.js`
306
+
307
+ **Step 3: Create basic Claude settings with hooks**:
308
+ Create `.claude/settings.json` with welcome message hook:
309
+ ```json
310
+ {
311
+ "hooks": {
312
+ "SessionStart": [
313
+ {
314
+ "matcher": "",
315
+ "hooks": [
316
+ {
317
+ "type": "command",
318
+ "command": "echo '🚀 AgileFlow loaded - Type /AgileFlow:help to see available commands'"
319
+ }
320
+ ]
321
+ }
322
+ ],
323
+ "UserPromptSubmit": [],
324
+ "Stop": []
325
+ }
326
+ }
327
+ ```
328
+
329
+ **Step 4: Auto-fix .gitignore for .claude directory** (Auto-applied):
330
+ ```bash
331
+ # Auto-add .claude user-specific files if not present
332
+ grep -E '^\\.claude/settings\\.local\\.json$' .gitignore 2>/dev/null || echo ".claude/settings.local.json" >> .gitignore
333
+ grep -E '^\\.claude/prompt-log\\.txt$' .gitignore 2>/dev/null || echo ".claude/prompt-log.txt" >> .gitignore
334
+ grep -E '^\\.claude/session\\.log$' .gitignore 2>/dev/null || echo ".claude/session.log" >> .gitignore
335
+ grep -E '^\\.claude/activity\\.log$' .gitignore 2>/dev/null || echo ".claude/activity.log" >> .gitignore
336
+ grep -E '^\\.claude/context\\.log$' .gitignore 2>/dev/null || echo ".claude/context.log" >> .gitignore
337
+ grep -E '^\\.claude/hook\\.log$' .gitignore 2>/dev/null || echo ".claude/hook.log" >> .gitignore
338
+ ```
339
+
340
+ **Note**: Setup automatically adds user-specific .claude files to .gitignore if missing. `.claude/settings.json` is committed to git (project-level config).
341
+
342
+ **Step 5: Create example settings.local.json template** (optional):
343
+ Create `.claude/settings.local.example.json` (commit to git):
344
+ ```json
345
+ {
346
+ "env": {
347
+ "USER_NAME": "Your Name",
348
+ "PROJECT_NAME": "Your Project"
349
+ }
350
+ }
351
+ ```
352
+
353
+ **Step 6: Update CLAUDE.md with hooks documentation**:
354
+ Add this section to project's CLAUDE.md:
355
+ ```markdown
356
+ ## Hooks System (AgileFlow v2.19.0+)
357
+
358
+ AgileFlow supports event-driven automation through Claude Code's official hooks system. Hooks are automatically triggered when Claude Code lifecycle events occur.
359
+
360
+ ### Configured Hooks
361
+
362
+ **SessionStart Hook**:
363
+ - Displays welcome message when Claude Code starts
364
+ - Current hook: Shows "🚀 AgileFlow loaded" message
365
+ - Located in: .claude/settings.json
366
+
367
+ ### Customizing Hooks
368
+
369
+ **To customize hooks**:
370
+ 1. Edit `.claude/settings.json`
371
+ 2. Add commands to SessionStart, UserPromptSubmit, or Stop events
372
+ 3. Restart Claude Code to apply changes
373
+
374
+ **Example - Add project context loading**:
375
+ ```json
376
+ {
377
+ "hooks": {
378
+ "SessionStart": [{
379
+ "hooks": [
380
+ {
381
+ "type": "command",
382
+ "command": "echo 'Project: $(node scripts/get-env.js PROJECT_NAME)'"
383
+ }
384
+ ]
385
+ }]
386
+ }
387
+ }
388
+ ```
389
+
390
+ **Example - Activity logging**:
391
+ ```json
392
+ {
393
+ "hooks": {
394
+ "UserPromptSubmit": [{
395
+ "hooks": [{
396
+ "type": "command",
397
+ "command": "echo '[LOG] Prompt at $(date)' >> .claude/activity.log"
398
+ }]
399
+ }]
400
+ }
401
+ }
402
+ ```
403
+
404
+ ### Dynamic Environment Variables
405
+
406
+ Use `scripts/get-env.js` to load environment variables from `.claude/settings.json` and `.claude/settings.local.json`:
407
+
408
+ **Create .claude/settings.local.json** (gitignored - your local config):
409
+ ```json
410
+ {
411
+ "env": {
412
+ "USER_NAME": "Alice",
413
+ "PROJECT_NAME": "MyApp"
414
+ }
415
+ }
416
+ ```
417
+
418
+ **Use in hooks**:
419
+ ```json
420
+ {
421
+ "hooks": {
422
+ "SessionStart": [{
423
+ "hooks": [{
424
+ "type": "command",
425
+ "command": "echo 'Welcome $(node scripts/get-env.js USER_NAME)!'"
426
+ }]
427
+ }]
428
+ }
429
+ }
430
+ ```
431
+
432
+ Changes to `.claude/settings.local.json` take effect immediately (no restart needed).
433
+
434
+ ### Security
435
+
436
+ - `.claude/settings.json` is committed (project-level config, shared with team)
437
+ - `.claude/settings.local.json` is gitignored (user-specific overrides)
438
+ - `.claude/settings.local.example.json` is committed (template for team)
439
+
440
+ See AgileFlow plugin documentation for advanced hooks patterns.
441
+ ```
442
+
443
+ **Print Next Steps**:
444
+ ```
445
+ ✅ Hooks system configured
446
+ ✅ .claude/settings.json created with SessionStart welcome message
447
+ ✅ scripts/get-env.js helper created
448
+ ✅ .gitignore updated (.claude user-specific files protected)
449
+ ✅ .claude/ directory created for settings
450
+ ✅ .claude/settings.local.example.json template created
451
+ ✅ CLAUDE.md updated with hooks documentation
452
+
453
+ Next steps for you:
454
+ 1. Customize hooks: Edit .claude/settings.json
455
+ 2. OPTIONAL: Create .claude/settings.local.json for user-specific environment variables
456
+ ═══════════════════════════════════════════════════════════
457
+ 3. 🔴🔴🔴 RESTART CLAUDE CODE NOW! (CRITICAL - DO NOT SKIP)
458
+ Quit completely (Cmd+Q), wait 5 seconds, restart
459
+ Hooks ONLY load on startup!
460
+ ═══════════════════════════════════════════════════════════
461
+ 4. Hooks will run automatically on SessionStart, UserPromptSubmit, Stop events
462
+
463
+ Next steps for team members:
464
+ 1. Pull latest code (includes .claude/settings.json project config)
465
+ 2. OPTIONAL: Create .claude/settings.local.json with their own environment variable overrides
466
+ ═══════════════════════════════════════════════════════════
467
+ 3. 🔴🔴🔴 RESTART CLAUDE CODE NOW! (CRITICAL - DO NOT SKIP)
468
+ Quit completely (Cmd+Q), wait 5 seconds, restart
469
+ Hooks ONLY load on startup!
470
+ ═══════════════════════════════════════════════════════════
471
+ 4. Hooks will run automatically!
472
+
473
+ Note: .claude/settings.json is committed to git (shared config). Team members can create .claude/settings.local.json for personal overrides (gitignored).
474
+ ```
475
+
476
+ AUTO-ARCHIVAL CONFIGURATION (v2.19.4+) - Story Status Management
477
+
478
+ **IMPORTANT**: As projects grow, `docs/09-agents/status.json` can exceed Claude Code's token limit (25k tokens), causing agents to fail reading it. Auto-archival solves this by moving old completed stories to an archive.
479
+
480
+ **The Problem**:
481
+ - status.json grows as stories complete
482
+ - Agents need to read status.json on every invocation
483
+ - File exceeds 25k token limit → agents break with "file too large" error
484
+ - Solution: Move old completed stories to status-archive.json
485
+
486
+ **Ask User for Archival Threshold**:
487
+ IF core system missing OR status.json not yet created, ask:
488
+ ```
489
+ 📦 Auto-Archival Configuration
490
+
491
+ How long should completed stories remain in active status before archiving?
492
+
493
+ 1. 3 days (very aggressive - keeps status.json very small)
494
+ 2. 7 days (weekly archival - recommended for fast-moving teams)
495
+ 3. 14 days (bi-weekly archival - good balance)
496
+ 4. 30 days (monthly archival - default, keeps recent context)
497
+ 5. Custom (specify number of days)
498
+
499
+ Your choice (1-5): [WAIT FOR INPUT]
500
+ ```
501
+
502
+ **Process User Choice**:
503
+ ```bash
504
+ # Store choice in docs/00-meta/agileflow-metadata.json
505
+ case $CHOICE in
506
+ 1) DAYS=3 ;;
507
+ 2) DAYS=7 ;;
508
+ 3) DAYS=14 ;;
509
+ 4) DAYS=30 ;;
510
+ 5)
511
+ echo "Enter custom days threshold: "
512
+ read DAYS
513
+ ;;
514
+ esac
515
+
516
+ # Update docs/00-meta/agileflow-metadata.json with archival config
517
+ METADATA_FILE="docs/00-meta/agileflow-metadata.json"
518
+ if [ -f "$METADATA_FILE" ]; then
519
+ # Update existing metadata
520
+ jq ".archival = {\"threshold_days\": $DAYS, \"enabled\": true} | .updated = \"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\"" "$METADATA_FILE" > "${METADATA_FILE}.tmp" && mv "${METADATA_FILE}.tmp" "$METADATA_FILE"
521
+ else
522
+ # Create new metadata (shouldn't happen if core system was set up)
523
+ cat > "$METADATA_FILE" << EOF
524
+ {
525
+ "version": "2.28.0",
526
+ "created": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
527
+ "updated": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
528
+ "archival": {
529
+ "threshold_days": $DAYS,
530
+ "enabled": true
531
+ }
532
+ }
533
+ EOF
534
+ fi
535
+
536
+ echo "✅ Configured $DAYS-day archival threshold in agileflow-metadata.json"
537
+ ```
538
+
539
+ **Add Auto-Archival Hook to .claude/settings.json**:
540
+ ```bash
541
+ # Read current .claude/settings.json
542
+ CURRENT_SETTINGS=$(cat .claude/settings.json)
543
+
544
+ # Add SessionStart hook for auto-archival check (if not already present)
545
+ if ! grep -q "archive-completed-stories.sh" .claude/settings.json 2>/dev/null; then
546
+ # Add auto-archival hook to SessionStart
547
+ # Script reads threshold from agileflow-metadata.json automatically
548
+ jq '.hooks.SessionStart += [{
549
+ "matcher": "",
550
+ "hooks": [{
551
+ "type": "command",
552
+ "command": "bash scripts/archive-completed-stories.sh > /dev/null 2>&1 &"
553
+ }]
554
+ }]' .claude/settings.json > .claude/settings.json.tmp && mv .claude/settings.json.tmp .claude/settings.json
555
+
556
+ echo "✅ Added auto-archival hook to .claude/settings.json"
557
+ else
558
+ echo "✅ Auto-archival hook already exists"
559
+ fi
560
+ ```
561
+
562
+ **Copy Scripts from Plugin**:
563
+ ```bash
564
+ # Copy archival script from AgileFlow plugin
565
+ cp ~/.claude-code/plugins/AgileFlow/scripts/archive-completed-stories.sh scripts/archive-completed-stories.sh
566
+ chmod +x scripts/archive-completed-stories.sh
567
+ echo "✅ Deployed archival script: scripts/archive-completed-stories.sh"
568
+
569
+ # Copy compression script from AgileFlow plugin (v2.20.0+)
570
+ cp ~/.claude-code/plugins/AgileFlow/scripts/compress-status.sh scripts/compress-status.sh
571
+ chmod +x scripts/compress-status.sh
572
+ echo "✅ Deployed compression script: scripts/compress-status.sh"
573
+ ```
574
+
575
+ **Update CLAUDE.md with Archival Documentation**:
576
+ Add this section to project's CLAUDE.md:
577
+ ```markdown
578
+ ## Auto-Archival System (AgileFlow v2.19.4+)
579
+
580
+ AgileFlow automatically manages `docs/09-agents/status.json` file size by archiving old completed stories to `docs/09-agents/status-archive.json`.
581
+
582
+ ### Why Auto-Archival?
583
+
584
+ **The Problem**:
585
+ - status.json grows as stories complete (can reach 100KB+ in active projects)
586
+ - Agents must read status.json on every invocation
587
+ - Files >25k tokens cause agents to fail with "file too large" error
588
+ - This breaks all agent workflows
589
+
590
+ **The Solution**:
591
+ - Automatically move completed stories older than threshold to status-archive.json
592
+ - Keep only active work (ready, in-progress, blocked) + recent completions in status.json
593
+ - Agents work fast with small, focused status.json
594
+ - Full history preserved in archive (nothing deleted)
595
+
596
+ ### Configuration
597
+
598
+ **Current Threshold**: $DAYS days (completed stories older than $DAYS days are archived)
599
+
600
+ **To change threshold**:
601
+ 1. Edit `docs/00-meta/agileflow-metadata.json`:
602
+ ```bash
603
+ # Update threshold to 7 days
604
+ jq '.archival.threshold_days = 7 | .updated = "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"' docs/00-meta/agileflow-metadata.json > tmp.json && mv tmp.json docs/00-meta/agileflow-metadata.json
605
+ ```
606
+ 2. Changes take effect immediately (no restart needed)
607
+ 3. Next SessionStart will use new threshold
608
+
609
+ ### How It Works
610
+
611
+ **Auto-Archival Hook** (runs on SessionStart):
612
+ - Checks `docs/09-agents/status.json` size
613
+ - If large enough, runs: `bash scripts/archive-completed-stories.sh <DAYS>`
614
+ - Moves completed stories older than threshold to status-archive.json
615
+ - Updates status.json with only active + recent stories
616
+ - Runs silently in background (no interruption)
617
+
618
+ ### File Structure
619
+
620
+ **docs/09-agents/status.json** (active work):
621
+ - Stories with status: ready, in-progress, blocked
622
+ - Completed stories within threshold (recent completions)
623
+ - Agents read this file (small, fast)
624
+
625
+ **docs/09-agents/status-archive.json** (historical):
626
+ - Completed stories older than threshold
627
+ - Full history preserved
628
+ - Agents rarely need to read this
629
+
630
+ ### Troubleshooting
631
+
632
+ **If agents fail with "file too large"**:
633
+ 1. Run manual archival: `bash scripts/archive-completed-stories.sh 7`
634
+ 2. Reduce threshold in `docs/00-meta/agileflow-metadata.json` (e.g., 3 days instead of 30)
635
+ 3. Verify auto-archival hook is in `hooks/hooks.json`
636
+
637
+ **To view archived stories**:
638
+ ```bash
639
+ # List all archived stories
640
+ jq '.stories | keys[]' docs/09-agents/status-archive.json
641
+
642
+ # View specific archived story
643
+ jq '.stories["US-0042"]' docs/09-agents/status-archive.json
644
+ ```
645
+ ```
646
+
647
+ **Print Configuration Summary**:
648
+ ```
649
+ ✅ Auto-Archival System configured
650
+ ✅ Threshold: $DAYS days
651
+ ✅ Archive script deployed: scripts/archive-completed-stories.sh
652
+ ✅ Compression script deployed: scripts/compress-status.sh (v2.20.0+)
653
+ ✅ Auto-archival hook added to .claude/settings.json
654
+ ✅ Settings saved to docs/00-meta/agileflow-metadata.json
655
+ ✅ CLAUDE.md updated with archival documentation
656
+
657
+ How it works:
658
+ - Every time Claude Code starts (SessionStart hook)
659
+ - Script checks docs/09-agents/status.json size
660
+ - Reads threshold from docs/00-meta/agileflow-metadata.json
661
+ - If needed, archives completed stories older than $DAYS days
662
+ - Keeps status.json small and fast for agents
663
+ - Full history preserved in docs/09-agents/status-archive.json
664
+
665
+ Manual archival and compression:
666
+ - Archival: bash scripts/archive-completed-stories.sh (reads from metadata)
667
+ - Archival with custom threshold: bash scripts/archive-completed-stories.sh 7
668
+ - Compression: /AgileFlow:compress (strips verbose fields if archival isn't enough)
669
+ - View status: ls -lh docs/09-agents/status*.json
670
+
671
+ Configuration:
672
+ - Stored in: docs/00-meta/agileflow-metadata.json
673
+ - Change threshold: jq '.archival.threshold_days = 7' docs/00-meta/agileflow-metadata.json
674
+ - Takes effect immediately (no restart needed)
675
+
676
+ Next steps:
677
+ - Auto-archival runs automatically on SessionStart
678
+ - Monitor file sizes: ls -lh docs/09-agents/status*.json
679
+ - If status.json grows too large, reduce threshold or run manual archival
680
+ ```
681
+
682
+ **Integration with Hooks System**:
683
+ - Auto-archival uses the hooks system configured above
684
+ - Runs silently in background on SessionStart
685
+ - No user interruption or prompts during normal usage
686
+ - Archives only when needed (status.json size triggers)
687
+
688
+ COMMAND EXECUTION
689
+ - Allowed after explicit YES with full preview. Good examples: `ls`, `tree`, `cat`, `grep`, formatters, running tests, creating files.
690
+ - Disallowed by default: destructive ops (`rm -rf`, force pushes) unless separately confirmed.
691
+
692
+ RULES
693
+ - Idempotent; update only missing files or managed sections.
694
+ - Validate JSON; no trailing commas.
695
+ - For every planned change, show a preview tree/diff and ask: Proceed? (YES/NO).
696
+ - After all writes/commands, print DONE + list of created/updated paths + executed commands with exit codes.
697
+
698
+ OUTPUT
699
+ - Initial detection summary (what was found)
700
+ - Preview tree and diffs (only for NEW files)
701
+ - runtime.json preview (if being created)
702
+ - **Git Attribution Policy** - Confirmation of user's preference (disabled/enabled)
703
+ - If chosen: CI workflow preview and branch-protection commands
704
+ - A rendered "commands catalog" (all prompts) to paste into your tool's custom commands UI
705
+ - Final status summary showing what was:
706
+ - ✅ Already configured (skipped)
707
+ - 🆕 Newly configured (created in this run)
708
+ - ⚠️ Partially configured (needs user action)