agileflow 3.4.0 → 3.4.1

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 (112) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +4 -4
  3. package/package.json +1 -1
  4. package/scripts/agileflow-welcome.js +79 -0
  5. package/scripts/claude-tmux.sh +12 -36
  6. package/scripts/lib/ac-test-matcher.js +452 -0
  7. package/scripts/lib/audit-registry.js +58 -2
  8. package/scripts/lib/configure-features.js +35 -0
  9. package/scripts/lib/model-profiles.js +25 -5
  10. package/scripts/lib/quality-gates.js +163 -0
  11. package/scripts/lib/signal-detectors.js +43 -0
  12. package/scripts/lib/status-writer.js +255 -0
  13. package/scripts/lib/story-claiming.js +128 -45
  14. package/scripts/lib/task-sync.js +32 -38
  15. package/scripts/lib/tmux-audit-monitor.js +611 -0
  16. package/scripts/lib/tool-registry.yaml +241 -0
  17. package/scripts/lib/tool-shed.js +441 -0
  18. package/scripts/native-team-observer.js +219 -0
  19. package/scripts/obtain-context.js +14 -0
  20. package/scripts/ralph-loop.js +30 -5
  21. package/scripts/smart-detect.js +21 -0
  22. package/scripts/spawn-audit-sessions.js +372 -44
  23. package/scripts/team-manager.js +19 -0
  24. package/src/core/agents/a11y-analyzer-aria.md +155 -0
  25. package/src/core/agents/a11y-analyzer-forms.md +162 -0
  26. package/src/core/agents/a11y-analyzer-keyboard.md +175 -0
  27. package/src/core/agents/a11y-analyzer-semantic.md +153 -0
  28. package/src/core/agents/a11y-analyzer-visual.md +158 -0
  29. package/src/core/agents/a11y-consensus.md +248 -0
  30. package/src/core/agents/ads-consensus.md +74 -0
  31. package/src/core/agents/ads-generate.md +145 -0
  32. package/src/core/agents/ads-performance-tracker.md +197 -0
  33. package/src/core/agents/api-quality-analyzer-conventions.md +148 -0
  34. package/src/core/agents/api-quality-analyzer-docs.md +176 -0
  35. package/src/core/agents/api-quality-analyzer-errors.md +183 -0
  36. package/src/core/agents/api-quality-analyzer-pagination.md +171 -0
  37. package/src/core/agents/api-quality-analyzer-versioning.md +143 -0
  38. package/src/core/agents/api-quality-consensus.md +214 -0
  39. package/src/core/agents/arch-analyzer-circular.md +148 -0
  40. package/src/core/agents/arch-analyzer-complexity.md +171 -0
  41. package/src/core/agents/arch-analyzer-coupling.md +146 -0
  42. package/src/core/agents/arch-analyzer-layering.md +151 -0
  43. package/src/core/agents/arch-analyzer-patterns.md +162 -0
  44. package/src/core/agents/arch-consensus.md +227 -0
  45. package/src/core/commands/adr.md +1 -0
  46. package/src/core/commands/ads/generate.md +238 -0
  47. package/src/core/commands/ads/health.md +327 -0
  48. package/src/core/commands/ads/test-plan.md +317 -0
  49. package/src/core/commands/ads/track.md +288 -0
  50. package/src/core/commands/ads.md +28 -16
  51. package/src/core/commands/assign.md +1 -0
  52. package/src/core/commands/audit.md +43 -6
  53. package/src/core/commands/babysit.md +90 -6
  54. package/src/core/commands/baseline.md +1 -0
  55. package/src/core/commands/blockers.md +1 -0
  56. package/src/core/commands/board.md +1 -0
  57. package/src/core/commands/changelog.md +1 -0
  58. package/src/core/commands/choose.md +1 -0
  59. package/src/core/commands/ci.md +1 -0
  60. package/src/core/commands/code/accessibility.md +347 -0
  61. package/src/core/commands/code/api.md +297 -0
  62. package/src/core/commands/code/architecture.md +297 -0
  63. package/src/core/commands/code/completeness.md +43 -6
  64. package/src/core/commands/code/legal.md +43 -6
  65. package/src/core/commands/code/logic.md +43 -6
  66. package/src/core/commands/code/performance.md +43 -6
  67. package/src/core/commands/code/security.md +43 -6
  68. package/src/core/commands/code/test.md +43 -6
  69. package/src/core/commands/configure.md +1 -0
  70. package/src/core/commands/council.md +1 -0
  71. package/src/core/commands/deploy.md +1 -0
  72. package/src/core/commands/diagnose.md +1 -0
  73. package/src/core/commands/docs.md +1 -0
  74. package/src/core/commands/epic/edit.md +213 -0
  75. package/src/core/commands/epic.md +1 -0
  76. package/src/core/commands/export.md +238 -0
  77. package/src/core/commands/help.md +16 -1
  78. package/src/core/commands/ideate/discover.md +7 -3
  79. package/src/core/commands/ideate/features.md +65 -4
  80. package/src/core/commands/ideate/new.md +158 -124
  81. package/src/core/commands/impact.md +1 -0
  82. package/src/core/commands/learn/explain.md +118 -0
  83. package/src/core/commands/learn/glossary.md +135 -0
  84. package/src/core/commands/learn/patterns.md +138 -0
  85. package/src/core/commands/learn/tour.md +126 -0
  86. package/src/core/commands/migrate/codemods.md +151 -0
  87. package/src/core/commands/migrate/plan.md +131 -0
  88. package/src/core/commands/migrate/scan.md +114 -0
  89. package/src/core/commands/migrate/validate.md +119 -0
  90. package/src/core/commands/multi-expert.md +1 -0
  91. package/src/core/commands/pr.md +1 -0
  92. package/src/core/commands/review.md +1 -0
  93. package/src/core/commands/sprint.md +1 -0
  94. package/src/core/commands/status/undo.md +191 -0
  95. package/src/core/commands/status.md +1 -0
  96. package/src/core/commands/story/edit.md +204 -0
  97. package/src/core/commands/story/view.md +29 -7
  98. package/src/core/commands/story-validate.md +1 -0
  99. package/src/core/commands/story.md +1 -0
  100. package/src/core/commands/tdd.md +1 -0
  101. package/src/core/commands/team/start.md +10 -6
  102. package/src/core/commands/tests.md +1 -0
  103. package/src/core/commands/verify.md +27 -1
  104. package/src/core/commands/workflow.md +2 -0
  105. package/src/core/teams/backend.json +41 -0
  106. package/src/core/teams/frontend.json +41 -0
  107. package/src/core/teams/qa.json +41 -0
  108. package/src/core/teams/solo.json +35 -0
  109. package/src/core/templates/agileflow-metadata.json +5 -0
  110. package/tools/cli/commands/setup.js +85 -3
  111. package/tools/cli/commands/update.js +42 -0
  112. package/tools/cli/installers/ide/claude-code.js +68 -0
@@ -0,0 +1,118 @@
1
+ ---
2
+ description: Deep explanation of code areas - not just what the code does, but WHY it was written this way, with git history and design reasoning
3
+ argument-hint: "[file|function|feature] [DEPTH=quick|thorough]"
4
+ ---
5
+
6
+ # /agileflow:learn:explain
7
+
8
+ Get a deep "why" explanation of code areas. Goes beyond what the code does to explain why it was written this way, what alternatives were considered, and what historical context shaped it.
9
+
10
+ ---
11
+
12
+ ## Quick Reference
13
+
14
+ ```
15
+ /agileflow:learn:explain src/auth/middleware.ts # Explain specific file
16
+ /agileflow:learn:explain handleCheckout # Explain a function
17
+ /agileflow:learn:explain "the caching layer" # Explain a concept/area
18
+ /agileflow:learn:explain app/api/ DEPTH=thorough # Thorough explanation
19
+ ```
20
+
21
+ ---
22
+
23
+ ## How It Works
24
+
25
+ 1. **Find the code** - Locate the target file, function, or feature
26
+ 2. **Read the code** - Understand what it does
27
+ 3. **Check git history** - Find when/why it was written or changed
28
+ 4. **Analyze design decisions** - Explain the "why" behind the approach
29
+ 5. **Surface alternatives** - What other approaches could have been used
30
+ 6. **Present explanation** - Clear, educational explanation with context
31
+
32
+ ---
33
+
34
+ ## Step-by-Step Process
35
+
36
+ ### STEP 1: Parse Arguments
37
+
38
+ ```
39
+ TARGET = file path, function name, or feature description
40
+ DEPTH = quick (3-5 min read) or thorough (10-15 min read)
41
+ ```
42
+
43
+ ### STEP 2: Find and Read Code
44
+
45
+ 1. If file path: read the file directly
46
+ 2. If function name: search codebase for the function
47
+ 3. If feature description: use `Explore` agent to find relevant files
48
+
49
+ ### STEP 3: Analyze Git History
50
+
51
+ ```bash
52
+ git log --follow --oneline {file} # See file history
53
+ git log -p --follow -S "{function}" -- . # Find when function was added/changed
54
+ git blame {file} # See who wrote each line and when
55
+ ```
56
+
57
+ ### STEP 4: Generate Explanation
58
+
59
+ Structure the explanation:
60
+
61
+ ```markdown
62
+ ## What This Code Does
63
+
64
+ {Clear explanation of the code's purpose and behavior}
65
+
66
+ ## Why It's Written This Way
67
+
68
+ {Design reasoning - what constraints or requirements led to this approach}
69
+
70
+ ### Historical Context
71
+ {Git history insights - when it was written, major changes, why changes were made}
72
+
73
+ ### Design Decisions
74
+ | Decision | Choice Made | Why | Alternative Considered |
75
+ |----------|-------------|-----|----------------------|
76
+ | {decision} | {choice} | {reasoning} | {what else could have been done} |
77
+
78
+ ## How It Connects
79
+
80
+ {Data flow diagram showing where this code fits in the system}
81
+
82
+ ```mermaid
83
+ graph LR
84
+ A[Input] --> B[This Code] --> C[Output]
85
+ B --> D[Side Effects]
86
+ ```
87
+
88
+ ## Key Concepts
89
+
90
+ | Concept | Explanation |
91
+ |---------|-------------|
92
+ | {term} | {what it means in this context} |
93
+
94
+ ## Gotchas
95
+
96
+ {Non-obvious behaviors, edge cases, or things to be careful about}
97
+ ```
98
+
99
+ ### STEP 5: Offer Follow-Up
100
+
101
+ ```
102
+ Explanation complete for {target}.
103
+
104
+ Options:
105
+ - Explain a related area
106
+ - Tour the broader system this belongs to
107
+ - See similar patterns elsewhere in the codebase
108
+ - Done
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Related Commands
114
+
115
+ - `/agileflow:learn:tour` - Guided codebase walkthrough
116
+ - `/agileflow:learn:patterns` - Design patterns catalog
117
+ - `/agileflow:learn:glossary` - Domain terminology
118
+ - `/agileflow:context:full` - Full project context
@@ -0,0 +1,135 @@
1
+ ---
2
+ description: Auto-generate domain terminology glossary from code identifiers, comments, and documentation with definitions and context
3
+ argument-hint: "[file|directory] [--update] [--format=table|definitions]"
4
+ ---
5
+
6
+ # /agileflow:learn:glossary
7
+
8
+ Auto-generate a domain terminology glossary by analyzing code identifiers, comments, and documentation. Maps domain-specific terms to their meaning in the codebase context.
9
+
10
+ ---
11
+
12
+ ## Quick Reference
13
+
14
+ ```
15
+ /agileflow:learn:glossary # Generate from entire project
16
+ /agileflow:learn:glossary src/ # Generate from specific directory
17
+ /agileflow:learn:glossary --update # Update existing glossary
18
+ /agileflow:learn:glossary --format=definitions # Definition-style output
19
+ ```
20
+
21
+ ---
22
+
23
+ ## How It Works
24
+
25
+ 1. **Extract identifiers** - Collect class names, function names, type names, constants
26
+ 2. **Analyze comments** - Find inline documentation and JSDoc descriptions
27
+ 3. **Detect domain terms** - Identify business/domain-specific vocabulary
28
+ 4. **Generate definitions** - Create clear, contextual definitions
29
+ 5. **Organize alphabetically** - Create a browsable reference
30
+
31
+ ---
32
+
33
+ ## Step-by-Step Process
34
+
35
+ ### STEP 1: Parse Arguments
36
+
37
+ ```
38
+ TARGET = file or directory (default: current directory)
39
+ UPDATE = --update flag to merge with existing glossary
40
+ FORMAT = table (default) or definitions
41
+ ```
42
+
43
+ ### STEP 2: Extract Domain Terms
44
+
45
+ Scan the codebase for domain-specific terms:
46
+
47
+ **Sources**:
48
+ - Class and interface names (e.g., `OrderFulfillment`, `PricingTier`)
49
+ - Type aliases and enums (e.g., `type OrderStatus = 'pending' | 'shipped'`)
50
+ - Constants (e.g., `MAX_RETRY_ATTEMPTS`, `DEFAULT_CURRENCY`)
51
+ - Database table/column names
52
+ - API endpoint names and parameters
53
+ - JSDoc comments with @description
54
+ - README and documentation files
55
+
56
+ **Filtering**:
57
+ - Exclude common programming terms (get, set, handle, process)
58
+ - Exclude framework terms (useState, useEffect, middleware)
59
+ - Focus on business/domain-specific vocabulary
60
+
61
+ ### STEP 3: Generate Definitions
62
+
63
+ For each term, generate a definition:
64
+
65
+ ```markdown
66
+ ### {Term}
67
+
68
+ **Type**: {class | type | function | constant | concept}
69
+ **Found in**: `{file_path}`
70
+ **Definition**: {clear, contextual definition}
71
+ **Example**: `{code usage example}`
72
+ **Related terms**: {list of related terms}
73
+ ```
74
+
75
+ ### STEP 4: Organize and Output
76
+
77
+ ```markdown
78
+ # Domain Glossary
79
+
80
+ **Project**: {project name}
81
+ **Generated**: {date}
82
+ **Terms**: {N}
83
+
84
+ ## A
85
+
86
+ ### Account
87
+ **Type**: model
88
+ **Found in**: `src/models/Account.ts`
89
+ **Definition**: A registered user entity with authentication credentials and profile information.
90
+ **Related**: User, Session, Subscription
91
+
92
+ ### ACL (Access Control List)
93
+ **Type**: concept
94
+ **Found in**: `src/auth/acl.ts`
95
+ **Definition**: Permission rules mapping roles to allowed operations on resources.
96
+ **Related**: Role, Permission, Authorization
97
+
98
+ ## B
99
+ ...
100
+ ```
101
+
102
+ Save to `docs/08-project/glossary.md`
103
+
104
+ ### STEP 5: Offer Follow-Up
105
+
106
+ ```
107
+ Glossary generated: [N] domain terms extracted from [M] files.
108
+
109
+ Options:
110
+ - Add/edit specific term definitions
111
+ - Generate glossary for specific module
112
+ - Explain a specific term in depth
113
+ - Done
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Output Formats
119
+
120
+ **Table format** (default):
121
+ | Term | Type | Definition | File |
122
+ |------|------|------------|------|
123
+ | Account | model | Registered user entity | models/Account.ts |
124
+
125
+ **Definitions format** (--format=definitions):
126
+ Full definition blocks with examples and related terms.
127
+
128
+ ---
129
+
130
+ ## Related Commands
131
+
132
+ - `/agileflow:learn:tour` - Guided codebase walkthrough
133
+ - `/agileflow:learn:explain` - Deep code explanation
134
+ - `/agileflow:learn:patterns` - Design patterns catalog
135
+ - `/agileflow:docs` - Documentation synchronization
@@ -0,0 +1,138 @@
1
+ ---
2
+ description: Catalog and explain design patterns actually used in the codebase with real code examples and rationale
3
+ argument-hint: "[pattern-name|category] [--generate]"
4
+ ---
5
+
6
+ # /agileflow:learn:patterns
7
+
8
+ Discover and catalog the design patterns actually used in the codebase. Shows real code examples, explains why each pattern was chosen, and documents the project's architectural vocabulary.
9
+
10
+ ---
11
+
12
+ ## Quick Reference
13
+
14
+ ```
15
+ /agileflow:learn:patterns # Discover all patterns
16
+ /agileflow:learn:patterns "repository" # Find repository pattern usage
17
+ /agileflow:learn:patterns --generate # Generate full pattern catalog
18
+ /agileflow:learn:patterns "error handling" # How errors are handled
19
+ /agileflow:learn:patterns creational # Creational patterns only
20
+ ```
21
+
22
+ ---
23
+
24
+ ## How It Works
25
+
26
+ 1. **Scan codebase** - Identify design patterns in use
27
+ 2. **Extract examples** - Find real code examples of each pattern
28
+ 3. **Document rationale** - Explain why each pattern was chosen
29
+ 4. **Categorize** - Group by pattern category
30
+ 5. **Generate catalog** - Create a reference document
31
+
32
+ ---
33
+
34
+ ## Step-by-Step Process
35
+
36
+ ### STEP 1: Parse Arguments
37
+
38
+ ```
39
+ TARGET = specific pattern name, category, or "all"
40
+ GENERATE = --generate flag to create/update catalog file
41
+ ```
42
+
43
+ ### STEP 2: Scan for Patterns
44
+
45
+ Use `Explore` agent to identify patterns:
46
+
47
+ | Category | Patterns to Detect |
48
+ |----------|-------------------|
49
+ | **Creational** | Factory, Builder, Singleton, Module |
50
+ | **Structural** | Adapter, Facade, Proxy, Decorator, Composite |
51
+ | **Behavioral** | Observer/PubSub, Strategy, Command, Middleware, State Machine |
52
+ | **Architectural** | MVC, Repository, Service Layer, CQRS, Event Sourcing |
53
+ | **Frontend** | Container/Presenter, HOC, Render Props, Custom Hooks, Compound Components |
54
+ | **Error Handling** | Error Boundary, Result Type, Error Middleware, Retry |
55
+ | **Data** | DAO, Active Record, Data Mapper, Unit of Work |
56
+
57
+ ### STEP 3: Extract Examples
58
+
59
+ For each detected pattern:
60
+
61
+ ```markdown
62
+ ## {Pattern Name}
63
+
64
+ **Category**: {Creational/Structural/Behavioral/etc.}
65
+ **Used in**: {N} places
66
+ **Key files**: {list}
67
+
68
+ ### What It Is
69
+ {Brief pattern description}
70
+
71
+ ### How We Use It
72
+ {Explanation specific to this codebase}
73
+
74
+ ### Real Example
75
+ \`\`\`{language}
76
+ // {file_path}:{line}
77
+ {actual code from the project}
78
+ \`\`\`
79
+
80
+ ### Why This Pattern
81
+ {Rationale for choosing this pattern over alternatives}
82
+
83
+ ### When to Use
84
+ {Guidelines for when to apply this pattern in new code}
85
+ ```
86
+
87
+ ### STEP 4: Generate Catalog (if --generate)
88
+
89
+ ```markdown
90
+ # Design Patterns Catalog
91
+
92
+ **Project**: {project name}
93
+ **Generated**: {date}
94
+ **Patterns Found**: {N}
95
+
96
+ ## Pattern Overview
97
+
98
+ | Pattern | Category | Usage Count | Key File |
99
+ |---------|----------|-------------|----------|
100
+ | {name} | {category} | {count} | {file} |
101
+
102
+ ## Detailed Patterns
103
+
104
+ {Each pattern with full documentation}
105
+
106
+ ## Patterns NOT Used (and Why)
107
+
108
+ | Pattern | Reason |
109
+ |---------|--------|
110
+ | {name} | {why it's not used or not appropriate} |
111
+
112
+ ## Conventions
113
+
114
+ {Project-specific conventions for applying patterns}
115
+ ```
116
+
117
+ Save to `docs/08-project/patterns/pattern-catalog-{YYYYMMDD}.md`
118
+
119
+ ### STEP 5: Offer Follow-Up
120
+
121
+ ```
122
+ Pattern catalog: [N] patterns found across [M] files.
123
+
124
+ Options:
125
+ - Explain a specific pattern in more detail
126
+ - See where to apply a pattern in new code
127
+ - Generate full catalog document
128
+ - Done
129
+ ```
130
+
131
+ ---
132
+
133
+ ## Related Commands
134
+
135
+ - `/agileflow:learn:tour` - Guided codebase walkthrough
136
+ - `/agileflow:learn:explain` - Deep code explanation
137
+ - `/agileflow:learn:glossary` - Domain terminology
138
+ - `/agileflow:code:architecture` - Architecture health audit
@@ -0,0 +1,126 @@
1
+ ---
2
+ description: Guided interactive codebase walkthrough with annotated stops explaining architecture, data flow, and key design decisions
3
+ argument-hint: "[topic|feature] [DEPTH=overview|detailed|deep-dive]"
4
+ ---
5
+
6
+ # /agileflow:learn:tour
7
+
8
+ Take an interactive guided tour through the codebase. The tour visits key files and explains architecture, data flow, and design decisions with annotated stops.
9
+
10
+ ---
11
+
12
+ ## Quick Reference
13
+
14
+ ```
15
+ /agileflow:learn:tour # Full architecture tour
16
+ /agileflow:learn:tour authentication # Tour the auth system
17
+ /agileflow:learn:tour "data flow" # Follow data through the system
18
+ /agileflow:learn:tour api DEPTH=deep-dive # Deep dive into API layer
19
+ /agileflow:learn:tour "new developer" # Onboarding tour
20
+ ```
21
+
22
+ ---
23
+
24
+ ## How It Works
25
+
26
+ 1. **Discover project structure** - Map the codebase architecture
27
+ 2. **Generate tour route** - Plan stops based on topic and depth
28
+ 3. **Interactive walkthrough** - Visit each stop with explanation
29
+ 4. **Ask questions** - Pause at each stop for user questions
30
+ 5. **Generate tour notes** - Save the tour as a reference document
31
+
32
+ ---
33
+
34
+ ## Step-by-Step Process
35
+
36
+ ### STEP 1: Parse Arguments
37
+
38
+ ```
39
+ TOPIC = specific feature/area or "full" for complete tour
40
+ DEPTH = overview (5-8 stops) | detailed (10-15 stops) | deep-dive (15-25 stops)
41
+ ```
42
+
43
+ ### STEP 2: Discover Project Structure
44
+
45
+ Use `Explore` agent to:
46
+ - Map directory structure and architecture pattern
47
+ - Identify entry points (main, index, app)
48
+ - Find key configuration files
49
+ - Detect framework and key libraries
50
+
51
+ ### STEP 3: Plan Tour Route
52
+
53
+ Generate a sequence of stops based on topic:
54
+
55
+ **Full Tour Route**:
56
+ 1. Entry point (main app file)
57
+ 2. Configuration and environment
58
+ 3. Routing/navigation structure
59
+ 4. Data models/schema
60
+ 5. API/service layer
61
+ 6. UI components (key ones)
62
+ 7. State management
63
+ 8. Authentication/authorization
64
+ 9. Testing approach
65
+
66
+ **Feature-Specific Tour**: Follow the feature through:
67
+ 1. Entry point (where user triggers it)
68
+ 2. Route/handler
69
+ 3. Business logic
70
+ 4. Data access
71
+ 5. Side effects (email, queue, etc.)
72
+ 6. UI rendering
73
+
74
+ ### STEP 4: Interactive Walkthrough
75
+
76
+ At each stop:
77
+
78
+ ```markdown
79
+ ## Stop {N}/{Total}: {Title}
80
+ 📍 `{file_path}`
81
+
82
+ {Read and explain the key code in this file}
83
+
84
+ **Why it matters**: {explanation of role in the system}
85
+ **Key patterns**: {design patterns used}
86
+ **Connected to**: {what files/modules this connects to}
87
+
88
+ ---
89
+ Continue to next stop? [Next | Ask a question | Jump to specific stop | End tour]
90
+ ```
91
+
92
+ ### STEP 5: Generate Tour Notes
93
+
94
+ Save a reference document:
95
+
96
+ ```markdown
97
+ # Codebase Tour: {Topic}
98
+
99
+ **Date**: {date}
100
+ **Stops**: {N}
101
+ **Coverage**: {files visited}
102
+
103
+ ## Tour Map
104
+ 1. {file} - {one-line summary}
105
+ 2. {file} - {one-line summary}
106
+ ...
107
+
108
+ ## Key Takeaways
109
+ - {insight 1}
110
+ - {insight 2}
111
+ ...
112
+
113
+ ## Architecture Diagram
114
+ {Mermaid diagram of the system}
115
+ ```
116
+
117
+ Save to `docs/08-project/tours/tour-{topic}-{YYYYMMDD}.md`
118
+
119
+ ---
120
+
121
+ ## Related Commands
122
+
123
+ - `/agileflow:learn:explain` - Deep "why" explanation of specific code
124
+ - `/agileflow:learn:patterns` - Catalog of design patterns used
125
+ - `/agileflow:learn:glossary` - Domain terminology reference
126
+ - `/agileflow:context:full` - Generate full project context
@@ -0,0 +1,151 @@
1
+ ---
2
+ description: Generate and execute AST-based codemods for automated code transformations with dry-run preview and rollback support
3
+ argument-hint: "[transformation] [file|directory] [--dry-run]"
4
+ ---
5
+
6
+ # /agileflow:migrate:codemods
7
+
8
+ Generate AST-based codemods for automated code transformations. Preview changes with dry-run before applying, with full rollback support.
9
+
10
+ ---
11
+
12
+ ## Quick Reference
13
+
14
+ ```
15
+ /agileflow:migrate:codemods "CommonJS to ESM" src/ # Generate CJS->ESM codemod
16
+ /agileflow:migrate:codemods "class to function components" # React class->function
17
+ /agileflow:migrate:codemods "enzyme to testing-library" # Test migration
18
+ /agileflow:migrate:codemods "require to import" --dry-run # Preview only
19
+ /agileflow:migrate:codemods "update API v2 to v3" src/api/ # API migration
20
+ ```
21
+
22
+ ---
23
+
24
+ ## How It Works
25
+
26
+ 1. **Analyze transformation** - Understand the before/after patterns
27
+ 2. **Scan target files** - Find all instances of the "before" pattern
28
+ 3. **Generate transformation** - Create the codemod logic (using regex, AST, or direct edit)
29
+ 4. **Dry-run preview** - Show what would change without modifying files
30
+ 5. **Apply changes** - Execute the transformation with backup
31
+ 6. **Verify** - Run tests to confirm nothing broke
32
+
33
+ ---
34
+
35
+ ## Step-by-Step Process
36
+
37
+ ### STEP 1: Parse Arguments
38
+
39
+ ```
40
+ TRANSFORMATION = description of the transformation
41
+ TARGET = file or directory (default: current directory)
42
+ DRY_RUN = --dry-run flag present (default: false, always dry-run first)
43
+ ```
44
+
45
+ ### STEP 2: Analyze Transformation
46
+
47
+ Delegate to `agileflow-refactor` agent:
48
+ - Understand the source and target patterns
49
+ - Identify edge cases and exceptions
50
+ - Determine if transformation is safe (reversible, no logic change)
51
+
52
+ ### STEP 3: Find All Instances
53
+
54
+ Scan target files for the source pattern:
55
+ - Count total instances
56
+ - Group by file
57
+ - Flag edge cases that need manual review
58
+
59
+ ### STEP 4: Generate Codemod
60
+
61
+ Create the transformation logic:
62
+
63
+ ```markdown
64
+ ## Codemod: {Transformation Name}
65
+
66
+ **Source Pattern**:
67
+ \`\`\`javascript
68
+ {before pattern}
69
+ \`\`\`
70
+
71
+ **Target Pattern**:
72
+ \`\`\`javascript
73
+ {after pattern}
74
+ \`\`\`
75
+
76
+ **Files Affected**: {N} files, {M} instances
77
+ **Edge Cases**: {list of cases needing manual review}
78
+ **Safety**: {safe/review-needed}
79
+ ```
80
+
81
+ ### STEP 5: Dry-Run Preview
82
+
83
+ **ALWAYS show dry-run first** before applying:
84
+
85
+ ```
86
+ Codemod Preview: "CommonJS to ESM"
87
+ ═══════════════════════════════════
88
+
89
+ Files affected: 15
90
+ Total transformations: 42
91
+ Edge cases (manual review): 3
92
+
93
+ Example transformation:
94
+ src/utils.js:1
95
+ - const { readFile } = require('fs');
96
+ + import { readFile } from 'fs';
97
+
98
+ src/utils.js:5
99
+ - module.exports = { helper };
100
+ + export { helper };
101
+
102
+ Edge cases (skipped):
103
+ src/dynamic-loader.js:12 - dynamic require()
104
+ src/config.js:8 - conditional require()
105
+ src/legacy.js:1 - require with side effects
106
+
107
+ Apply transformations? [Y/n/review-edge-cases]
108
+ ```
109
+
110
+ ### STEP 6: Apply and Verify
111
+
112
+ After user approval:
113
+ 1. Create git stash or backup
114
+ 2. Apply transformations file by file
115
+ 3. Run linter to fix formatting
116
+ 4. Run tests to verify
117
+ 5. Show summary of changes
118
+
119
+ ### STEP 7: Offer Next Steps
120
+
121
+ ```
122
+ Codemod applied: [N] transformations in [M] files. [E] edge cases need manual review.
123
+
124
+ Options:
125
+ - Run tests to verify changes (Recommended)
126
+ - Review edge cases manually
127
+ - Undo all changes (git checkout)
128
+ - Continue with next migration step
129
+ ```
130
+
131
+ ---
132
+
133
+ ## Common Codemods
134
+
135
+ | Transformation | Description |
136
+ |---------------|-------------|
137
+ | CJS to ESM | `require()` -> `import`, `module.exports` -> `export` |
138
+ | Class to function | React class components -> function components with hooks |
139
+ | Enzyme to RTL | Enzyme test assertions -> React Testing Library |
140
+ | PropTypes to TypeScript | Runtime PropTypes -> TypeScript interfaces |
141
+ | Callbacks to async/await | Callback-based code -> async/await |
142
+ | var to const/let | `var` declarations -> `const`/`let` |
143
+
144
+ ---
145
+
146
+ ## Related Commands
147
+
148
+ - `/agileflow:migrate:scan` - Detect migration opportunities
149
+ - `/agileflow:migrate:plan` - Generate migration roadmap
150
+ - `/agileflow:migrate:validate` - Post-migration verification
151
+ - `/agileflow:verify` - Run tests after transformation