forge-orkes 0.3.7 → 0.3.9
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.
- package/package.json +1 -1
- package/template/.claude/settings.json +6 -2
- package/template/.claude/skills/executing/SKILL.md +69 -1
- package/template/.claude/skills/forge/SKILL.md +12 -15
- package/template/.claude/skills/initializing/SKILL.md +80 -1
- package/template/.claude/skills/reviewing/SKILL.md +437 -0
- package/template/.claude/skills/verifying/SKILL.md +3 -3
- package/template/.forge/templates/project.yml +11 -0
- package/template/CLAUDE.md +29 -11
- package/template/.claude/skills/auditing/SKILL.md +0 -314
- package/template/.claude/skills/refactoring/SKILL.md +0 -168
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: auditing
|
|
3
|
-
description: "Use after verifying passes to assess overall application health before milestone completion. Runs security audit (10 categories) and architecture audit (scaling, maintainability, code health). This is the pre-release gate — it answers 'is this codebase healthy enough to ship?'"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Auditing: Health Audit Before Milestone Completion
|
|
7
|
-
|
|
8
|
-
You are the pre-release gate. After `verifying` confirms the work delivers what was promised, you assess whether the codebase is healthy enough to ship. Two parallel audits — security and architecture — produce a structured health report that determines whether the milestone can complete.
|
|
9
|
-
|
|
10
|
-
## When to Trigger
|
|
11
|
-
|
|
12
|
-
- **Automatically** after `verifying` returns a PASSED verdict (Standard and Full tiers)
|
|
13
|
-
- **On-demand** at any time via user request
|
|
14
|
-
|
|
15
|
-
## Process Overview
|
|
16
|
-
|
|
17
|
-
1. Read project context (`.forge/project.yml`) to determine tech stack
|
|
18
|
-
2. Scope the audit — glob all source files, summarize what will be scanned
|
|
19
|
-
3. Spawn two parallel subagents: Security Audit + Architecture Audit
|
|
20
|
-
4. Collect results, score per-category, determine overall status
|
|
21
|
-
5. Write health report to `.forge/audits/milestone-{id}-health-report.md`
|
|
22
|
-
6. Route based on results: healthy → complete, issues → user decides
|
|
23
|
-
|
|
24
|
-
## Step 1: Read Context
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
Read: .forge/project.yml → tech stack, framework, database, dependencies
|
|
28
|
-
Read: .forge/state/milestone-{id}.yml → milestone ID and name
|
|
29
|
-
Read: .forge/constitution.md → active architectural gates (if exists)
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Determine which security categories apply based on the tech stack. For example:
|
|
33
|
-
- No database → SQL/NoSQL Injection is N/A
|
|
34
|
-
- No frontend → XSS Prevention is N/A
|
|
35
|
-
- No CI/CD config → Pipeline Security is N/A
|
|
36
|
-
|
|
37
|
-
## Step 2: Scope the Audit
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
Glob: src/**/*.{ts,tsx,js,jsx,py,go,rs,java} (adapt to project language)
|
|
41
|
-
Glob: **/*.env*, **/docker-compose*, **/.github/workflows/*
|
|
42
|
-
Glob: **/next.config*, **/vite.config*, **/webpack.config*
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Present scope summary to user:
|
|
46
|
-
*"Health audit scope: {N} source files, {N} config files. Scanning for security vulnerabilities (10 categories) and architectural health (4 dimensions). This will take a moment."*
|
|
47
|
-
|
|
48
|
-
Build explicit file lists for each subagent — pass file paths, not globs, so nothing is missed.
|
|
49
|
-
|
|
50
|
-
## Step 3: Spawn Parallel Audits
|
|
51
|
-
|
|
52
|
-
Spawn both audits as fresh-context subagents. Each receives:
|
|
53
|
-
- The explicit file list for their scope
|
|
54
|
-
- The tech stack from `project.yml`
|
|
55
|
-
- Their specific audit instructions (below)
|
|
56
|
-
|
|
57
|
-
### Part 1: Security Audit (subagent)
|
|
58
|
-
|
|
59
|
-
Spawn a security auditor agent with a fresh context window.
|
|
60
|
-
|
|
61
|
-
**10 Security Categories:**
|
|
62
|
-
|
|
63
|
-
| # | Category | What It Checks |
|
|
64
|
-
|---|----------|---------------|
|
|
65
|
-
| 1 | Authentication & Authorization | Every endpoint has auth middleware; role checks before data access |
|
|
66
|
-
| 2 | Data Scoping / Tenant Isolation | Queries scoped to correct user/tenant; no cross-tenant data leaks |
|
|
67
|
-
| 3 | Input Validation | Request bodies/params validated before use in queries or logic |
|
|
68
|
-
| 4 | Error Information Leakage | No stack traces, DB schemas, or internal details in API responses |
|
|
69
|
-
| 5 | XSS Prevention | No unsanitized user content injected into DOM |
|
|
70
|
-
| 6 | SQL/NoSQL Injection | All queries use parameterized placeholders, no string interpolation |
|
|
71
|
-
| 7 | Secrets Management | No hardcoded keys/tokens; `.env` in `.gitignore`; `process.env` usage |
|
|
72
|
-
| 8 | CORS Policy | No wildcard `*` origins in production; appropriate method restrictions |
|
|
73
|
-
| 9 | HTTP Security Headers | CSP, X-Frame-Options, HSTS, X-Content-Type-Options, Referrer-Policy |
|
|
74
|
-
| 10 | CI/CD Pipeline Security | Secrets via secrets context, not hardcoded in workflow files |
|
|
75
|
-
|
|
76
|
-
**Agent behavior rules:**
|
|
77
|
-
- Read every file in the provided list. No sampling or skipping.
|
|
78
|
-
- Every finding must have: file path, line number, what's wrong, severity, remediation.
|
|
79
|
-
- Understand context before flagging — read surrounding code, check for middleware, wrappers, and higher-order protections.
|
|
80
|
-
- Document intentionally public endpoints; don't flag them as vulnerabilities.
|
|
81
|
-
- Severity is firm: `critical` = exploitable vulnerability, `warning` = defense-in-depth gap, `info` = observation.
|
|
82
|
-
- Prefer false negatives over false positives — only flag what you're confident about.
|
|
83
|
-
- Categories that don't apply to this project's stack → mark as N/A with brief explanation.
|
|
84
|
-
|
|
85
|
-
**Project adaptation:** Adapt checks to the detected stack:
|
|
86
|
-
- Express vs Next.js vs Fastify endpoint patterns
|
|
87
|
-
- PostgreSQL vs MongoDB vs SQLite query patterns
|
|
88
|
-
- GitHub Actions vs GitLab CI vs other CI systems
|
|
89
|
-
- React vs Vue vs Svelte frontend patterns
|
|
90
|
-
|
|
91
|
-
**Output format** (return to orchestrator):
|
|
92
|
-
|
|
93
|
-
```yaml
|
|
94
|
-
security_audit:
|
|
95
|
-
files_scanned: N
|
|
96
|
-
categories:
|
|
97
|
-
- id: 1
|
|
98
|
-
name: "Authentication & Authorization"
|
|
99
|
-
status: passed | warning | critical | na
|
|
100
|
-
findings:
|
|
101
|
-
- file: "src/api/users.ts"
|
|
102
|
-
line: 42
|
|
103
|
-
severity: critical | warning | info
|
|
104
|
-
issue: "Description of what's wrong"
|
|
105
|
-
remediation: "How to fix it"
|
|
106
|
-
notes: "Optional context about intentional decisions"
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Part 2: Architecture Audit (subagent)
|
|
110
|
-
|
|
111
|
-
Spawn an architecture auditor agent with a fresh context window.
|
|
112
|
-
|
|
113
|
-
**4 Architecture Dimensions:**
|
|
114
|
-
|
|
115
|
-
| Dimension | What It Checks |
|
|
116
|
-
|-----------|---------------|
|
|
117
|
-
| **Scalability** | Synchronous blocking calls, missing pagination, unbounded queries, N+1 query patterns, missing caching opportunities, single points of failure, hardcoded limits |
|
|
118
|
-
| **Maintainability** | Code complexity hotspots (files >300 lines, deeply nested logic >4 levels, god components/classes), circular dependencies, duplicated logic that warrants abstraction |
|
|
119
|
-
| **Code Health** | Dead code / unused exports, TODO/FIXME inventory with age, test coverage gaps (untested critical paths), stale/vulnerable dependencies |
|
|
120
|
-
| **Structural Quality** | Separation of concerns violations (business logic in UI layer), inconsistent patterns across similar features, missing error boundaries, API contract consistency |
|
|
121
|
-
|
|
122
|
-
**Agent behavior rules:**
|
|
123
|
-
- Check actual code, not theoretical concerns.
|
|
124
|
-
- Every finding references specific files with evidence.
|
|
125
|
-
- Severity: `critical` = architectural debt that will cause production issues or block future work, `warning` = quality concern worth addressing, `info` = improvement opportunity.
|
|
126
|
-
- Respect existing ADRs in `.forge/decisions/` — don't flag intentional architectural choices as issues.
|
|
127
|
-
- Respect constitutional articles in `.forge/constitution.md` — if the constitution permits a pattern, don't flag it.
|
|
128
|
-
|
|
129
|
-
**Output format** (return to orchestrator):
|
|
130
|
-
|
|
131
|
-
```yaml
|
|
132
|
-
architecture_audit:
|
|
133
|
-
files_scanned: N
|
|
134
|
-
dimensions:
|
|
135
|
-
- name: "Scalability"
|
|
136
|
-
status: passed | warning | critical
|
|
137
|
-
findings:
|
|
138
|
-
- file: "src/api/products.ts"
|
|
139
|
-
line: 87
|
|
140
|
-
severity: critical | warning | info
|
|
141
|
-
issue: "Unbounded query with no pagination"
|
|
142
|
-
remediation: "Add limit/offset parameters"
|
|
143
|
-
- name: "Maintainability"
|
|
144
|
-
status: passed | warning | critical
|
|
145
|
-
findings: []
|
|
146
|
-
- name: "Code Health"
|
|
147
|
-
status: passed | warning | critical
|
|
148
|
-
findings: []
|
|
149
|
-
- name: "Structural Quality"
|
|
150
|
-
status: passed | warning | critical
|
|
151
|
-
findings: []
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Step 4: Score Results
|
|
155
|
-
|
|
156
|
-
After both subagents return, compute scores.
|
|
157
|
-
|
|
158
|
-
**Per-category scoring:**
|
|
159
|
-
|
|
160
|
-
| Status | Meaning |
|
|
161
|
-
|--------|---------|
|
|
162
|
-
| `passed` | No issues found |
|
|
163
|
-
| `warning` | Non-critical issues (info-level also maps here) |
|
|
164
|
-
| `critical` | Real vulnerabilities or architectural blockers |
|
|
165
|
-
| `na` | Category doesn't apply to this project |
|
|
166
|
-
|
|
167
|
-
**Overall status:**
|
|
168
|
-
|
|
169
|
-
| Overall | Condition |
|
|
170
|
-
|---------|-----------|
|
|
171
|
-
| `passed` | ALL categories and dimensions passed or N/A |
|
|
172
|
-
| `warnings_only` | One or more warnings, zero critical |
|
|
173
|
-
| `issues_found` | One or more critical findings |
|
|
174
|
-
|
|
175
|
-
## Step 5: Write Health Report
|
|
176
|
-
|
|
177
|
-
Create `.forge/audits/` directory if needed. Write to `.forge/audits/milestone-{id}-health-report.md`.
|
|
178
|
-
|
|
179
|
-
**YAML frontmatter:**
|
|
180
|
-
|
|
181
|
-
```yaml
|
|
182
|
-
---
|
|
183
|
-
milestone_id: {id}
|
|
184
|
-
milestone_name: "{name}"
|
|
185
|
-
audited: "{ISO 8601 timestamp}"
|
|
186
|
-
status: passed | warnings_only | issues_found
|
|
187
|
-
security:
|
|
188
|
-
status: passed | warnings_only | issues_found
|
|
189
|
-
categories_passed: N
|
|
190
|
-
categories_warning: N
|
|
191
|
-
categories_critical: N
|
|
192
|
-
categories_na: N
|
|
193
|
-
architecture:
|
|
194
|
-
status: passed | warnings_only | issues_found
|
|
195
|
-
scalability: passed | warning | critical
|
|
196
|
-
maintainability: passed | warning | critical
|
|
197
|
-
code_health: passed | warning | critical
|
|
198
|
-
structural_quality: passed | warning | critical
|
|
199
|
-
total_files_scanned: N
|
|
200
|
-
---
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
**Body structure:**
|
|
204
|
-
|
|
205
|
-
```markdown
|
|
206
|
-
# Health Audit Report: {milestone name}
|
|
207
|
-
|
|
208
|
-
## Executive Summary
|
|
209
|
-
{1-3 sentences: overall health assessment, key findings, recommendation}
|
|
210
|
-
|
|
211
|
-
## Security Findings
|
|
212
|
-
|
|
213
|
-
### Category 1: Authentication & Authorization — {STATUS}
|
|
214
|
-
| File | Line | Severity | Issue | Remediation |
|
|
215
|
-
|------|------|----------|-------|-------------|
|
|
216
|
-
| ... | ... | ... | ... | ... |
|
|
217
|
-
|
|
218
|
-
{Repeat for each category. N/A categories get a single line: "N/A — {reason}"}
|
|
219
|
-
|
|
220
|
-
## Architecture Findings
|
|
221
|
-
|
|
222
|
-
### Scalability — {STATUS}
|
|
223
|
-
| File | Line | Severity | Issue | Remediation |
|
|
224
|
-
|------|------|----------|-------|-------------|
|
|
225
|
-
| ... | ... | ... | ... | ... |
|
|
226
|
-
|
|
227
|
-
{Repeat for each dimension}
|
|
228
|
-
|
|
229
|
-
## Public Endpoints
|
|
230
|
-
{List of intentionally public endpoints documented during security audit}
|
|
231
|
-
|
|
232
|
-
## Files Scanned
|
|
233
|
-
{Count and list of all files scanned across both audits}
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
**Health trend tracking:** If a previous audit exists for an earlier milestone (check `.forge/audits/` for prior reports), compare results and note improvements or regressions in the executive summary.
|
|
237
|
-
|
|
238
|
-
## Step 6: Route Based on Results
|
|
239
|
-
|
|
240
|
-
### HEALTHY (all passed)
|
|
241
|
-
|
|
242
|
-
Update `.forge/state/milestone-{id}.yml`:
|
|
243
|
-
- Set `current.status` to `refactoring`
|
|
244
|
-
|
|
245
|
-
Present to user:
|
|
246
|
-
*"Health audit passed. No security vulnerabilities or architectural concerns found. Moving to refactoring review."*
|
|
247
|
-
|
|
248
|
-
→ Route to `refactoring` skill.
|
|
249
|
-
|
|
250
|
-
### NEEDS ATTENTION (critical issues found)
|
|
251
|
-
|
|
252
|
-
Do NOT mark milestone complete. Present to user:
|
|
253
|
-
|
|
254
|
-
*"Health audit found critical issues that should be addressed before shipping:"*
|
|
255
|
-
|
|
256
|
-
Inline the top 3 findings per critical category so the user sees them immediately (don't make them open the report).
|
|
257
|
-
|
|
258
|
-
Then offer choices:
|
|
259
|
-
|
|
260
|
-
*"Options:"*
|
|
261
|
-
- **A. Fix critical issues** — return to `planning` in fix mode with findings as requirements
|
|
262
|
-
- **B. Accept risk and continue** — document accepted risks in report, proceed to refactoring review
|
|
263
|
-
|
|
264
|
-
If user chooses A:
|
|
265
|
-
- Create fix requirements from critical findings
|
|
266
|
-
- Route to `planning` skill in fix mode
|
|
267
|
-
- After fix execution, re-run `auditing` (not full `verifying` — just the audit)
|
|
268
|
-
|
|
269
|
-
If user chooses B:
|
|
270
|
-
- Append "Accepted Risks" section to the health report with user's acknowledgment
|
|
271
|
-
- Update `.forge/state/milestone-{id}.yml`: set `current.status` to `refactoring`
|
|
272
|
-
- → Route to `refactoring` skill.
|
|
273
|
-
|
|
274
|
-
### ACCEPTABLE WITH CAVEATS (warnings only)
|
|
275
|
-
|
|
276
|
-
Present to user:
|
|
277
|
-
|
|
278
|
-
*"Health audit passed with warnings — no critical issues, but {N} items worth noting. See the full report at `.forge/audits/milestone-{id}-health-report.md`."*
|
|
279
|
-
|
|
280
|
-
Then offer choices:
|
|
281
|
-
- **A. Continue to refactoring review** — accept warnings as known items
|
|
282
|
-
- **B. Fix warnings** — address before continuing
|
|
283
|
-
|
|
284
|
-
If user chooses A:
|
|
285
|
-
- Document accepted warnings in report
|
|
286
|
-
- Update `.forge/state/milestone-{id}.yml`: set `current.status` to `refactoring`
|
|
287
|
-
- → Route to `refactoring` skill.
|
|
288
|
-
|
|
289
|
-
If user chooses B:
|
|
290
|
-
- Create fix requirements from warning findings
|
|
291
|
-
- Route to `planning` in fix mode
|
|
292
|
-
- After fix execution, re-run `auditing`
|
|
293
|
-
|
|
294
|
-
## Gate Type: Soft Gate
|
|
295
|
-
|
|
296
|
-
This is a soft gate — critical issues strongly recommend fixing before completion, but the user can accept risk and proceed. Rationale:
|
|
297
|
-
- Some issues may be acceptable known risks for the deployment context
|
|
298
|
-
- Some findings may be false positives despite the conservative flagging approach
|
|
299
|
-
- Non-production or internal tools may have different risk tolerances
|
|
300
|
-
- The user always has final authority over ship decisions
|
|
301
|
-
|
|
302
|
-
The report documents the decision either way, creating an audit trail.
|
|
303
|
-
|
|
304
|
-
## Phase Handoff
|
|
305
|
-
|
|
306
|
-
After auditing routes to refactoring (all three paths: HEALTHY, accepted risk, accepted warnings):
|
|
307
|
-
|
|
308
|
-
1. **Verify persistence** — Confirm health report is written to `.forge/audits/milestone-{id}-health-report.md`
|
|
309
|
-
2. **Update state** — Set `current.status` to `refactoring` in `.forge/state/milestone-{id}.yml`
|
|
310
|
-
3. **Recommend context clear:**
|
|
311
|
-
|
|
312
|
-
*"Health audit complete. Report written to `.forge/audits/`. I recommend clearing context (`/clear`) before the refactoring review — the refactoring scanner spawns a fresh agent with the git diff and health report, so a clean context ensures accurate scanning.*
|
|
313
|
-
|
|
314
|
-
*Ready to continue? Clear context and invoke `/forge` to resume."*
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: refactoring
|
|
3
|
-
description: "Review code built during a milestone for refactoring opportunities. Runs after auditing passes. Produces a structured backlog of improvements the user can work through via quick-tasking. Soft gate — review items, add to backlog, complete milestone."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Refactoring: Post-Milestone Code Review for Improvement Opportunities
|
|
7
|
-
|
|
8
|
-
You review the code built during a milestone and catalog opportunities for improvement. This is not about correctness (that's `verifying`) or health (that's `auditing`) — it's about identifying code that works but could be cleaner, simpler, or more consistent.
|
|
9
|
-
|
|
10
|
-
## When to Trigger
|
|
11
|
-
|
|
12
|
-
- **Automatically** after `auditing` completes (all three paths: HEALTHY, NEEDS ATTENTION after fix, ACCEPTABLE WITH CAVEATS after accept)
|
|
13
|
-
- **On-demand** at any time via user request
|
|
14
|
-
|
|
15
|
-
## Step 1: Read Context
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
Read: .forge/project.yml → tech stack, conventions
|
|
19
|
-
Read: .forge/state/milestone-{id}.yml → milestone ID, name, phases completed
|
|
20
|
-
Read: .forge/audits/milestone-{id}-health-report.md → health findings (avoid overlap)
|
|
21
|
-
Read: .forge/refactor-backlog.yml → existing backlog items (if any)
|
|
22
|
-
Read: .forge/constitution.md → active architectural gates (if exists)
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Determine the milestone's starting point for the git diff:
|
|
26
|
-
- Check git log for the commit tagged or noted as the milestone start
|
|
27
|
-
- If unavailable, use the first commit after the previous milestone's completion date
|
|
28
|
-
- Fallback: ask the user for the starting commit or branch
|
|
29
|
-
|
|
30
|
-
## Step 2: Scan Milestone Code
|
|
31
|
-
|
|
32
|
-
Spawn a fresh agent with isolated context. Pass it:
|
|
33
|
-
- The explicit list of files changed during the milestone (from `git diff --name-only {start}..HEAD`)
|
|
34
|
-
- The tech stack from `project.yml`
|
|
35
|
-
- The health report findings (so it doesn't duplicate auditing's work)
|
|
36
|
-
- The constitution (so it respects intentional decisions)
|
|
37
|
-
|
|
38
|
-
**The agent scans for 6 categories:**
|
|
39
|
-
|
|
40
|
-
| # | Category | What to Look For |
|
|
41
|
-
|---|----------|-----------------|
|
|
42
|
-
| 1 | **Duplication** | Similar logic in 2+ places that could be extracted into a shared function, hook, or utility |
|
|
43
|
-
| 2 | **Complexity hotspots** | Functions >50 lines, nesting >3 levels deep, high cyclomatic complexity, overly long files |
|
|
44
|
-
| 3 | **Naming & clarity** | Unclear variable/function names, misleading abstractions, functions that do more than their name suggests |
|
|
45
|
-
| 4 | **Pattern inconsistency** | Same thing done differently across the milestone's files (e.g., error handling, data fetching, state management) |
|
|
46
|
-
| 5 | **Dead code** | Unused functions, unreachable branches, commented-out code left behind, unused imports |
|
|
47
|
-
| 6 | **Abstraction issues** | Over-engineered helpers used once, repeated inline code that warrants extraction, premature or missing abstractions |
|
|
48
|
-
|
|
49
|
-
**Agent behavior rules:**
|
|
50
|
-
- Read every file in the diff. No sampling.
|
|
51
|
-
- Every finding must reference a specific file and line range.
|
|
52
|
-
- Understand context — don't flag intentional patterns documented in the constitution.
|
|
53
|
-
- Don't duplicate findings already in the health report from auditing.
|
|
54
|
-
- Estimate effort for each item: `quick` (< 30 min, under 50 lines) or `standard` (needs planning).
|
|
55
|
-
- Suggest a concrete approach for each finding, not just "refactor this."
|
|
56
|
-
- Prefer fewer high-quality findings over many low-signal ones.
|
|
57
|
-
|
|
58
|
-
**Output format** (return to orchestrator):
|
|
59
|
-
|
|
60
|
-
```yaml
|
|
61
|
-
findings:
|
|
62
|
-
- category: duplication
|
|
63
|
-
file: "src/api/users.ts"
|
|
64
|
-
lines: "42-67"
|
|
65
|
-
description: "Duplicate validation logic — same email check in createUser and updateUser"
|
|
66
|
-
effort: quick
|
|
67
|
-
suggested_approach: "Extract shared validateEmail() helper to src/utils/validation.ts"
|
|
68
|
-
- category: complexity
|
|
69
|
-
file: "src/components/Dashboard.tsx"
|
|
70
|
-
lines: "120-245"
|
|
71
|
-
description: "Dashboard render function is 125 lines with 4 levels of nesting"
|
|
72
|
-
effort: standard
|
|
73
|
-
suggested_approach: "Extract stat cards, chart section, and filter bar into subcomponents"
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Step 3: Present Findings to User
|
|
77
|
-
|
|
78
|
-
Group findings by category. Show each with:
|
|
79
|
-
- File and line range
|
|
80
|
-
- What the issue is
|
|
81
|
-
- Estimated effort
|
|
82
|
-
- Suggested approach
|
|
83
|
-
|
|
84
|
-
Present top findings (max 10 initially). If there are more, mention the count.
|
|
85
|
-
|
|
86
|
-
*"I found {N} refactoring opportunities in the code built during this milestone:"*
|
|
87
|
-
|
|
88
|
-
Then for each category with findings:
|
|
89
|
-
|
|
90
|
-
*"**Duplication** ({N} items):*
|
|
91
|
-
*1. `src/api/users.ts:42-67` — Duplicate email validation in createUser and updateUser. Quick fix: extract shared helper. [Accept / Dismiss]*
|
|
92
|
-
*2. ...*"
|
|
93
|
-
|
|
94
|
-
## Step 4: User Triage
|
|
95
|
-
|
|
96
|
-
The user can respond with:
|
|
97
|
-
- **Accept** (individual item) → add to backlog
|
|
98
|
-
- **Dismiss** (individual item) → skip, not a real issue or intentional
|
|
99
|
-
- **Accept all** → bulk add all remaining items to backlog
|
|
100
|
-
- **Dismiss all** → skip everything, no backlog items added
|
|
101
|
-
|
|
102
|
-
For dismissed items, optionally ask for a brief reason (helps calibrate future scans).
|
|
103
|
-
|
|
104
|
-
## Step 5: Write Backlog
|
|
105
|
-
|
|
106
|
-
Read existing `.forge/refactor-backlog.yml` (if any). Determine the next item ID by incrementing from the highest existing ID.
|
|
107
|
-
|
|
108
|
-
Append accepted items to `.forge/refactor-backlog.yml`:
|
|
109
|
-
|
|
110
|
-
```yaml
|
|
111
|
-
items:
|
|
112
|
-
- id: R001
|
|
113
|
-
milestone: 1
|
|
114
|
-
category: duplication
|
|
115
|
-
file: "src/api/users.ts"
|
|
116
|
-
lines: "42-67"
|
|
117
|
-
description: "Duplicate validation logic — same email check in createUser and updateUser"
|
|
118
|
-
effort: quick
|
|
119
|
-
suggested_approach: "Extract shared validateEmail() helper"
|
|
120
|
-
status: pending
|
|
121
|
-
added: "2026-03-18"
|
|
122
|
-
completed: null
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
If the file doesn't exist yet, create it from the template at `.forge/templates/refactor-backlog.yml`.
|
|
126
|
-
|
|
127
|
-
Present summary:
|
|
128
|
-
*"Added {N} items to the refactor backlog. {M} dismissed. You can work these anytime — pending items with `effort: quick` will show up as available Quick tasks when you start a session."*
|
|
129
|
-
|
|
130
|
-
## Step 6: Route
|
|
131
|
-
|
|
132
|
-
Update `.forge/state/milestone-{id}.yml`:
|
|
133
|
-
- Set `current.status` to `complete`
|
|
134
|
-
|
|
135
|
-
Update `.forge/state/index.yml`:
|
|
136
|
-
- Set milestone status to `complete`
|
|
137
|
-
- Update `last_updated` timestamp
|
|
138
|
-
|
|
139
|
-
Present to user:
|
|
140
|
-
*"Milestone [{name}] is complete. {N} refactoring items are in the backlog for whenever you want to tackle them."*
|
|
141
|
-
|
|
142
|
-
If Beads is installed, run `bd complete` to update the dependency graph.
|
|
143
|
-
|
|
144
|
-
## Gate Type: Soft Gate
|
|
145
|
-
|
|
146
|
-
This is a soft gate — it presents opportunities but never blocks milestone completion. Rationale:
|
|
147
|
-
- Refactoring is improvement, not correctness. The code already works (verified) and is healthy (audited).
|
|
148
|
-
- Users should review opportunities but aren't forced to act on them immediately.
|
|
149
|
-
- Backlog items persist across sessions and can be worked whenever it makes sense.
|
|
150
|
-
- Some items may become irrelevant as the codebase evolves — that's fine.
|
|
151
|
-
|
|
152
|
-
## Backlog Lifecycle
|
|
153
|
-
|
|
154
|
-
Backlog items follow this lifecycle:
|
|
155
|
-
|
|
156
|
-
```
|
|
157
|
-
pending → in_progress → done
|
|
158
|
-
pending → dismissed (during triage or later review)
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
Items with `effort: quick` can be picked up directly via `quick-tasking`.
|
|
162
|
-
Items with `effort: standard` should go through the Standard tier flow.
|
|
163
|
-
|
|
164
|
-
When working a backlog item:
|
|
165
|
-
1. `forge` surfaces it as an available task
|
|
166
|
-
2. User selects it
|
|
167
|
-
3. Route to `quick-tasking` or Standard tier based on effort
|
|
168
|
-
4. On completion, update the item's `status` to `done` and set `completed` date
|