@jamie-tam/forge 6.0.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.
- package/LICENSE +21 -0
- package/README.md +389 -0
- package/agents/architect.md +92 -0
- package/agents/builder.md +122 -0
- package/agents/code-reviewer.md +107 -0
- package/agents/concept-designer.md +207 -0
- package/agents/craft-reviewer.md +132 -0
- package/agents/critic.md +130 -0
- package/agents/doc-writer.md +85 -0
- package/agents/dreamer.md +129 -0
- package/agents/e2e-runner.md +89 -0
- package/agents/gotcha-hunter.md +127 -0
- package/agents/prototype-builder.md +193 -0
- package/agents/prototype-codifier.md +204 -0
- package/agents/prototype-reviewer.md +163 -0
- package/agents/security-reviewer.md +108 -0
- package/agents/spec-reviewer.md +94 -0
- package/agents/tracer.md +98 -0
- package/agents/wireframer.md +109 -0
- package/commands/abort.md +25 -0
- package/commands/bugfix.md +151 -0
- package/commands/evolve.md +118 -0
- package/commands/feature.md +236 -0
- package/commands/forge.md +100 -0
- package/commands/greenfield.md +185 -0
- package/commands/hotfix.md +98 -0
- package/commands/refactor.md +147 -0
- package/commands/resume.md +25 -0
- package/commands/setup.md +201 -0
- package/commands/status.md +27 -0
- package/commands/task-force.md +110 -0
- package/commands/validate.md +12 -0
- package/dist/__tests__/active-manifest.test.js +272 -0
- package/dist/__tests__/copy.test.js +96 -0
- package/dist/__tests__/gate-check.test.js +384 -0
- package/dist/__tests__/wiki.test.js +472 -0
- package/dist/__tests__/work-manifest.test.js +304 -0
- package/dist/active-manifest.js +229 -0
- package/dist/cli.js +158 -0
- package/dist/copy.js +124 -0
- package/dist/gate-check.js +326 -0
- package/dist/hooks.js +60 -0
- package/dist/init.js +140 -0
- package/dist/manifest.js +90 -0
- package/dist/merge.js +77 -0
- package/dist/paths.js +36 -0
- package/dist/uninstall.js +216 -0
- package/dist/update.js +158 -0
- package/dist/verify-manifest.js +65 -0
- package/dist/verify.js +98 -0
- package/dist/wiki-ui.js +310 -0
- package/dist/wiki.js +364 -0
- package/dist/work-manifest.js +798 -0
- package/hooks/config/gate-requirements.json +79 -0
- package/hooks/hooks.json +143 -0
- package/hooks/scripts/analyze-telemetry.sh +114 -0
- package/hooks/scripts/gate-enforcer.sh +164 -0
- package/hooks/scripts/pre-compact.sh +90 -0
- package/hooks/scripts/session-start.sh +81 -0
- package/hooks/scripts/telemetry.sh +41 -0
- package/hooks/scripts/wiki-lint.sh +87 -0
- package/hooks/templates/AGENTS.md.template +48 -0
- package/hooks/templates/CLAUDE.md.template +45 -0
- package/package.json +55 -0
- package/protocols/README.md +40 -0
- package/protocols/codex.md +151 -0
- package/protocols/graphify.md +156 -0
- package/references/common/agent-coordination.md +65 -0
- package/references/common/coding-standards.md +54 -0
- package/references/common/feature-tracking.md +21 -0
- package/references/common/io-protocol.md +36 -0
- package/references/common/phases.md +57 -0
- package/references/common/quality-gates.md +130 -0
- package/references/common/skill-authoring.md +154 -0
- package/references/common/skill-compliance.md +30 -0
- package/references/python/standards.md +44 -0
- package/references/react/standards.md +61 -0
- package/references/typescript/standards.md +42 -0
- package/rules/common/forge-system.md +59 -0
- package/rules/common/git-workflow.md +40 -0
- package/rules/common/guardrails.md +37 -0
- package/rules/common/quality-gates.md +18 -0
- package/rules/common/security.md +50 -0
- package/rules/common/skill-selection.md +78 -0
- package/rules/common/testing.md +58 -0
- package/rules/common/verification.md +39 -0
- package/skills/build-pr-workflow/SKILL.md +301 -0
- package/skills/build-pr-workflow/references/pr-template.md +62 -0
- package/skills/build-pr-workflow/references/subagent-merge.md +47 -0
- package/skills/build-pr-workflow/references/worktree-setup.md +125 -0
- package/skills/build-prototype/SKILL.md +264 -0
- package/skills/build-scaffold/SKILL.md +340 -0
- package/skills/build-tdd/SKILL.md +89 -0
- package/skills/build-wireframe/SKILL.md +110 -0
- package/skills/build-wireframe/assets/baseline-template.html +486 -0
- package/skills/build-wireframe/references/demo-walkthroughs.md +170 -0
- package/skills/build-wireframe/references/gotchas.md +188 -0
- package/skills/build-wireframe/references/legend-lines.md +141 -0
- package/skills/concept-slides/SKILL.md +192 -0
- package/skills/deliver-db-migration/SKILL.md +466 -0
- package/skills/deliver-deploy/SKILL.md +407 -0
- package/skills/deliver-onboarding/SKILL.md +198 -0
- package/skills/deliver-onboarding/references/document-templates.md +393 -0
- package/skills/deliver-onboarding/templates/getting-started.md +122 -0
- package/skills/discover-codebase-analysis/SKILL.md +448 -0
- package/skills/discover-requirements/SKILL.md +418 -0
- package/skills/discover-requirements/templates/prd.md +99 -0
- package/skills/discover-requirements/templates/technical-spec.md +123 -0
- package/skills/discover-requirements/templates/user-stories.md +76 -0
- package/skills/harden/SKILL.md +214 -0
- package/skills/iterate-prototype/SKILL.md +241 -0
- package/skills/plan-architecture/SKILL.md +457 -0
- package/skills/plan-architecture/templates/adr-template.md +52 -0
- package/skills/plan-architecture/templates/api-contract.md +99 -0
- package/skills/plan-architecture/templates/db-schema.md +81 -0
- package/skills/plan-architecture/templates/system-design.md +111 -0
- package/skills/plan-brainstorm/SKILL.md +433 -0
- package/skills/plan-design-system/SKILL.md +279 -0
- package/skills/plan-task-decompose/SKILL.md +454 -0
- package/skills/quality-code-review/SKILL.md +286 -0
- package/skills/quality-security-audit/SKILL.md +292 -0
- package/skills/quality-security-audit/references/audit-report-template.md +89 -0
- package/skills/quality-security-audit/references/owasp-checks.md +178 -0
- package/skills/quality-test-execution/SKILL.md +435 -0
- package/skills/quality-test-plan/SKILL.md +297 -0
- package/skills/quality-test-plan/references/test-type-guide.md +263 -0
- package/skills/quality-test-plan/templates/e2e-test-plan.md +72 -0
- package/skills/quality-test-plan/templates/integration-test-plan.md +74 -0
- package/skills/quality-test-plan/templates/load-test-plan.md +111 -0
- package/skills/quality-test-plan/templates/smoke-test-plan.md +68 -0
- package/skills/quality-test-plan/templates/unit-test-plan.md +56 -0
- package/skills/quality-uiux/SKILL.md +481 -0
- package/skills/support-debug/SKILL.md +464 -0
- package/skills/support-dream/SKILL.md +213 -0
- package/skills/support-gotcha/SKILL.md +249 -0
- package/skills/support-runtime-reachability/SKILL.md +190 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-01-passes-app-use/src/app.ts +7 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-01-passes-app-use/src/handlers/cases.ts +7 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-02-orphan-no-app-use/src/app.ts +8 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-02-orphan-no-app-use/src/handlers/cases.ts +7 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-03-orphan-import-only/src/App.tsx +5 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-03-orphan-import-only/src/components/RingingBanner.tsx +7 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-03-orphan-import-only/src/hooks/useTwilio.ts +6 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-04-jsx-component-rendered/src/App.tsx +5 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-04-jsx-component-rendered/src/components/MyComp.tsx +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-05-jsx-component-not-rendered/src/App.tsx +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-05-jsx-component-not-rendered/src/components/Orphan.tsx +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-06-class-instantiated/src/lib/Service.ts +6 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-06-class-instantiated/src/main.ts +4 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-07-class-not-instantiated/src/lib/Lonely.ts +5 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-07-class-not-instantiated/src/main.ts +2 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-08-default-export-imported-and-called/src/handler.ts +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-08-default-export-imported-and-called/src/main.ts +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-09-default-export-orphan/src/handler.ts +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-09-default-export-orphan/src/main.ts +2 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-10-aliased-named-export/src/lib.ts +5 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-10-aliased-named-export/src/main.ts +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-11-re-export-chain/src/lib/index.ts +1 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-11-re-export-chain/src/lib/internal.ts +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-11-re-export-chain/src/main.ts +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-12-test-only-caller/src/util.test.ts +5 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-12-test-only-caller/src/util.ts +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-13-gated-pending-annotation/src/future.ts +4 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-14-untraceable-annotation/src/decorated.ts +4 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-15-untraceable-empty/src/lazy.ts +4 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-16-python-module/src/lib.py +15 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-16-python-module/src/main.py +5 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-17-router-use/src/parent.ts +5 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-17-router-use/src/routes/cases.ts +5 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-18-shadowed-name-fp/src/lib/foo.ts +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-18-shadowed-name-fp/src/other.ts +8 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-19-same-name-different-module/src/handlers/cases.ts +4 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-19-same-name-different-module/src/handlers/users.ts +4 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-19-same-name-different-module/src/main.ts +5 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-20-aliased-import-usage/src/handlers/cases.ts +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-20-aliased-import-usage/src/main.ts +4 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-21-mixed-default-and-named/src/lib.ts +5 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-21-mixed-default-and-named/src/main.ts +5 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-22-dynamic-import-then-caller/src/lib.ts +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-22-dynamic-import-then-caller/src/main.ts +8 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-23-dynamic-import-with-space/src/lib.ts +3 -0
- package/skills/support-runtime-reachability/scripts/__fixtures__/case-23-dynamic-import-with-space/src/main.ts +7 -0
- package/skills/support-runtime-reachability/scripts/check.mjs +638 -0
- package/skills/support-runtime-reachability/scripts/check.test.mjs +244 -0
- package/skills/support-skill-validator/SKILL.md +194 -0
- package/skills/support-skill-validator/references/false-positives.md +59 -0
- package/skills/support-skill-validator/references/validation-checks.md +280 -0
- package/skills/support-system-guide/SKILL.md +311 -0
- package/skills/support-task-force/SKILL.md +265 -0
- package/skills/support-task-force/references/dispatch-pattern.md +178 -0
- package/skills/support-task-force/references/synthesis-template.md +126 -0
- package/skills/support-wiki-bootstrap/SKILL.md +37 -0
- package/skills/support-wiki-lint/SKILL.md +196 -0
- package/skills/support-wiki-lint/scripts/lint.mjs +488 -0
- package/skills/support-wiki-lint/scripts/lint.test.mjs +196 -0
- package/templates/README.md +23 -0
- package/templates/aiwiki/CLAUDE.md.template +78 -0
- package/templates/aiwiki/schemas/architecture.md +118 -0
- package/templates/aiwiki/schemas/convention.md +112 -0
- package/templates/aiwiki/schemas/decision.md +144 -0
- package/templates/aiwiki/schemas/gotcha.md +118 -0
- package/templates/aiwiki/schemas/oracle.md +105 -0
- package/templates/aiwiki/schemas/session.md +125 -0
- package/templates/manifests/bugfix.yaml +41 -0
- package/templates/manifests/feature.yaml +69 -0
- package/templates/manifests/greenfield.yaml +61 -0
- package/templates/manifests/hotfix.yaml +45 -0
- package/templates/manifests/refactor.yaml +44 -0
- package/templates/manifests/v5/SCHEMA.md +327 -0
- package/templates/manifests/v5/feature.yaml +77 -0
- package/templates/manifests/v6/SCHEMA.md +199 -0
- package/templates/wiki-html/dream-detail.html +378 -0
- package/templates/wiki-html/dreams-list.html +155 -0
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: discover-codebase-analysis
|
|
3
|
+
description: "Use when the user opens an unfamiliar repo, says 'explain this codebase', 'what does this project do', 'map the architecture', 'find the entry points', 'what patterns does this use', or before any /feature or /harden on an existing codebase. Produces a structured codebase report (entry points, layers, conventions, hot files). Skip for greenfield work — no codebase to analyse."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Discover Codebase Analysis
|
|
7
|
+
|
|
8
|
+
Systematically analyze an existing codebase to understand its structure, patterns, conventions, and risks before planning any changes. This skill produces a structured report.
|
|
9
|
+
|
|
10
|
+
**Announce at start:** "I'm using the discover-codebase-analysis skill to map the existing codebase before we plan changes."
|
|
11
|
+
|
|
12
|
+
<HARD-GATE>
|
|
13
|
+
On existing projects, this skill MUST run before plan-brainstorm. Do NOT propose architectural changes without understanding what already exists. Skipping codebase analysis leads to designs that fight the existing code instead of working with it.
|
|
14
|
+
</HARD-GATE>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## I/O Contract
|
|
19
|
+
|
|
20
|
+
| Field | Value |
|
|
21
|
+
|---|---|
|
|
22
|
+
| **Requires** | Existing codebase accessible in the working directory or specified path |
|
|
23
|
+
| **Produces** | `.forge/work/{type}/{name}/codebase-analysis.md` |
|
|
24
|
+
| **Feeds into** | `plan-brainstorm`, `plan-architecture`, `plan-task-decompose` |
|
|
25
|
+
| **Updates manifest** | `artifacts.codebase-analysis` |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Agent Dispatch
|
|
30
|
+
|
|
31
|
+
Dispatch the **architect** subagent (Opus) to analyze the architecture. The architect agent specializes in system design evaluation, tradeoff analysis, and identifying architectural patterns and risks that a standard analysis might miss. The architect determines the appropriate depth based on the codebase size and complexity.
|
|
32
|
+
|
|
33
|
+
**Note for legacy codebases:** Files exceeding 500 lines should be analyzed using `lsp_document_symbols` or read with `offset` + `limit` to avoid consuming excessive context.
|
|
34
|
+
|
|
35
|
+
## Checklist
|
|
36
|
+
|
|
37
|
+
Complete these steps in order:
|
|
38
|
+
|
|
39
|
+
1. **Identify the scope of analysis** -- full project or targeted area
|
|
40
|
+
2. **Graphify guard** -- run the status check from `protocols/graphify.md`. Offer install/build/update as appropriate. Graph data enriches steps 3-9.
|
|
41
|
+
3. **Map project structure** -- directories, key files, entry points. If graph available: use communities as subsystem map, god nodes as critical components.
|
|
42
|
+
4. **Identify technology stack** -- languages, frameworks, libraries, build tools
|
|
43
|
+
5. **Analyze code patterns** -- architectural style, state management, error handling. If graph available: validate architecture claims against community boundaries.
|
|
44
|
+
6. **Map conventions** -- naming, file organization, import style, component patterns
|
|
45
|
+
7. **Trace dependency chains** -- for the area being modified. If graph available: use edge confidence labels (EXTRACTED = trusted, INFERRED = verify, AMBIGUOUS = investigate).
|
|
46
|
+
8. **Assess test coverage** -- what is tested, what is not, testing approach
|
|
47
|
+
9. **Flag risks** -- tight coupling, missing tests, tech debt, security concerns. If graph available: god nodes as coupling risks, AMBIGUOUS edges as investigation targets.
|
|
48
|
+
10. **Write analysis report** -- structured document to `.forge/work/{type}/{name}/codebase-analysis.md`
|
|
49
|
+
11. **Update feature manifest** -- record artifact path
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Process
|
|
54
|
+
|
|
55
|
+
### Step 1: Identify Scope of Analysis
|
|
56
|
+
|
|
57
|
+
Ask the user what they intend to change. This scopes the analysis:
|
|
58
|
+
|
|
59
|
+
> "Before I analyze the codebase, what area are you planning to modify? This helps me focus the analysis on the most relevant parts."
|
|
60
|
+
>
|
|
61
|
+
> A) A specific feature area (tell me which one)
|
|
62
|
+
> B) A specific set of files or directories
|
|
63
|
+
> C) I need a full project overview first
|
|
64
|
+
> D) I'm not sure yet -- help me understand the whole project
|
|
65
|
+
|
|
66
|
+
For targeted analysis (A/B): deep-dive the specified area plus one level of dependencies.
|
|
67
|
+
For full overview (C/D): breadth-first scan of the entire project, then depth on areas the user selects.
|
|
68
|
+
|
|
69
|
+
### Step 1.5: Codex Mode Check
|
|
70
|
+
|
|
71
|
+
Now that scope is known, run the Codex consent flow from `protocols/codex.md`. The selected mode applies for the rest of this skill's invocation — do not re-prompt at later Codex steps.
|
|
72
|
+
|
|
73
|
+
- **Takeover:** Dispatch Codex with the scope from Step 1 + skill methodology + working directory. Skip Steps 2-10 (Codex runs them). Claude reviews Codex's output at Step 10.
|
|
74
|
+
- **Verify** or **Skip / Codex unavailable:** Proceed with Steps 2-11 below. Step 9.5 will dispatch Codex to review Claude's analysis (Verify only).
|
|
75
|
+
|
|
76
|
+
### Step 2: Graphify Guard
|
|
77
|
+
|
|
78
|
+
Run the full graphify status check from `protocols/graphify.md` — see that protocol for the complete status table. Summary:
|
|
79
|
+
|
|
80
|
+
1. Check three things:
|
|
81
|
+
- `graphify-out/graph.json` exists?
|
|
82
|
+
- `graphify --version` succeeds (CLI installed)?
|
|
83
|
+
- `~/.claude/skills/graphify/SKILL.md` exists (skill installed — required for `/graphify` to fire)?
|
|
84
|
+
2. Offer the appropriate action based on status (install / install skill / build / update / use as-is). See the full table in `protocols/graphify.md`.
|
|
85
|
+
3. If user accepts build/update → invoke the `/graphify` skill, then continue.
|
|
86
|
+
4. If user declines update BUT `graph.json` already exists → continue using the existing graph as-is. Do NOT skip graph enrichment.
|
|
87
|
+
5. If user declines install/build AND no graph exists → proceed without graph enrichment.
|
|
88
|
+
|
|
89
|
+
**If graph is available after this step** (freshly built, updated, or existing), extract: god nodes, top 20 communities by cohesion, edge confidence labels (EXTRACTED/INFERRED/AMBIGUOUS).
|
|
90
|
+
|
|
91
|
+
<GATE>
|
|
92
|
+
STOP. If graphify install or graph build was offered, wait for the user's response before proceeding. Graph data enriches Steps 3-9 — loading it now saves significant tokens in later steps.
|
|
93
|
+
</GATE>
|
|
94
|
+
|
|
95
|
+
### Step 3: Map Project Structure
|
|
96
|
+
|
|
97
|
+
Examine the directory layout and identify:
|
|
98
|
+
|
|
99
|
+
- **Root structure**: What lives at the top level? Configuration files, source directories, documentation.
|
|
100
|
+
- **Source organization**: Is it organized by feature, by layer, by module, or mixed?
|
|
101
|
+
- **Entry points**: Where does execution start? (main files, index files, route definitions, CLI entry points)
|
|
102
|
+
- **Configuration**: Build config, environment config, deployment config locations.
|
|
103
|
+
- **Test structure**: Where do tests live? Colocated with source? Separate directory? Both?
|
|
104
|
+
- **Generated/vendored code**: Identify directories that are not hand-written (node_modules, vendor, dist, build).
|
|
105
|
+
|
|
106
|
+
Output a tree overview, excluding generated directories:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
project/
|
|
110
|
+
src/
|
|
111
|
+
api/ -- REST API layer (Express routes)
|
|
112
|
+
services/ -- Business logic
|
|
113
|
+
models/ -- Database models (Prisma)
|
|
114
|
+
utils/ -- Shared utilities
|
|
115
|
+
tests/
|
|
116
|
+
unit/ -- Unit tests (Jest)
|
|
117
|
+
integration/ -- Integration tests
|
|
118
|
+
config/ -- Environment configuration
|
|
119
|
+
scripts/ -- Build and deploy scripts
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Step 4: Identify Technology Stack
|
|
123
|
+
|
|
124
|
+
Catalog the technology choices by reading configuration files:
|
|
125
|
+
|
|
126
|
+
| Category | What to Check | Files to Read |
|
|
127
|
+
|---|---|---|
|
|
128
|
+
| **Language** | Primary and secondary languages | File extensions, config files |
|
|
129
|
+
| **Framework** | Web framework, ORM, test runner | package.json, requirements.txt, go.mod, Cargo.toml |
|
|
130
|
+
| **Database** | Type, ORM, migration tool | Config files, schema files, docker-compose |
|
|
131
|
+
| **Build tools** | Bundler, compiler, task runner | webpack.config, tsconfig, Makefile, build.gradle |
|
|
132
|
+
| **CI/CD** | Pipeline configuration | .github/workflows, .gitlab-ci.yml, Jenkinsfile |
|
|
133
|
+
| **Infrastructure** | Container, orchestration, cloud | Dockerfile, docker-compose, terraform, k8s manifests |
|
|
134
|
+
| **Package manager** | npm, yarn, pnpm, pip, cargo | Lock files (package-lock.json, yarn.lock, etc.) |
|
|
135
|
+
|
|
136
|
+
Note version constraints where visible (package.json engines, .python-version, .node-version, .tool-versions).
|
|
137
|
+
|
|
138
|
+
### Step 5: Analyze Code Patterns
|
|
139
|
+
|
|
140
|
+
Examine actual source files to identify the patterns in use. For each pattern, cite a specific file as an example:
|
|
141
|
+
|
|
142
|
+
**Architecture patterns:**
|
|
143
|
+
- Layered? (controller -> service -> repository)
|
|
144
|
+
- Domain-driven? (bounded contexts, aggregates)
|
|
145
|
+
- Event-driven? (event bus, pub/sub, message queues)
|
|
146
|
+
- Microservices? Monolith? Modular monolith?
|
|
147
|
+
|
|
148
|
+
**API patterns:**
|
|
149
|
+
- REST? GraphQL? gRPC? Mixed?
|
|
150
|
+
- How are routes defined? (decorators, file-based routing, explicit registration)
|
|
151
|
+
- How are request/response types defined? (TypeScript interfaces, Pydantic models, protobuf)
|
|
152
|
+
- How is authentication handled?
|
|
153
|
+
- How is authorization handled?
|
|
154
|
+
|
|
155
|
+
**State management:**
|
|
156
|
+
- Server-side: How is state stored? (database, cache, session, in-memory)
|
|
157
|
+
- Client-side: What state management library? (Redux, Zustand, Context, signals)
|
|
158
|
+
|
|
159
|
+
**Error handling:**
|
|
160
|
+
- How are errors created? (custom error classes, error codes, plain strings)
|
|
161
|
+
- How are errors propagated? (throw/catch, Result types, error callbacks)
|
|
162
|
+
- How are errors reported to users? (error responses, toast notifications, error boundaries)
|
|
163
|
+
- Is there a centralized error handler?
|
|
164
|
+
|
|
165
|
+
**Data validation:**
|
|
166
|
+
- Where does validation happen? (API layer, service layer, both)
|
|
167
|
+
- What validation library? (Zod, Joi, class-validator, Pydantic, hand-written)
|
|
168
|
+
- How are validation errors returned to callers?
|
|
169
|
+
|
|
170
|
+
**Logging and observability:**
|
|
171
|
+
- What logging library? What log levels?
|
|
172
|
+
- Is there structured logging?
|
|
173
|
+
- Any tracing or metrics?
|
|
174
|
+
|
|
175
|
+
### Step 6: Map Conventions
|
|
176
|
+
|
|
177
|
+
Document the conventions that new code MUST follow to maintain consistency:
|
|
178
|
+
|
|
179
|
+
**Naming conventions:**
|
|
180
|
+
- File naming: camelCase, kebab-case, PascalCase, snake_case?
|
|
181
|
+
- Variable naming: camelCase for variables, SCREAMING_CASE for constants?
|
|
182
|
+
- Function naming: verb-first? (getUser, createOrder, handleSubmit)
|
|
183
|
+
- Component naming: PascalCase? Matches filename?
|
|
184
|
+
- Test naming: describe/it style? test_ prefix? What pattern?
|
|
185
|
+
|
|
186
|
+
**File organization:**
|
|
187
|
+
- One class/component per file? Or multiple?
|
|
188
|
+
- Index files for re-exports? Barrel pattern?
|
|
189
|
+
- Where do types/interfaces live? Colocated or centralized?
|
|
190
|
+
- Where do constants live?
|
|
191
|
+
|
|
192
|
+
**Import patterns:**
|
|
193
|
+
- Absolute imports? Relative imports? Path aliases?
|
|
194
|
+
- Import ordering convention? (external, internal, relative)
|
|
195
|
+
- Named vs default exports?
|
|
196
|
+
|
|
197
|
+
**Code style:**
|
|
198
|
+
- Is there a linter config? (.eslintrc, .flake8, clippy.toml)
|
|
199
|
+
- Is there a formatter config? (.prettierrc, black config, rustfmt.toml)
|
|
200
|
+
- Max line length? Indentation style?
|
|
201
|
+
|
|
202
|
+
**Component patterns** (if frontend):
|
|
203
|
+
- Functional or class components?
|
|
204
|
+
- Props interface naming? (Props suffix, I prefix)
|
|
205
|
+
- Hook patterns? Custom hooks for logic?
|
|
206
|
+
- Styling approach? (CSS modules, styled-components, Tailwind, inline)
|
|
207
|
+
|
|
208
|
+
### Step 7: Trace Dependency Chains
|
|
209
|
+
|
|
210
|
+
For the area being modified, map what depends on it and what it depends on:
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
[files that import from the target area]
|
|
214
|
+
|
|
|
215
|
+
v
|
|
216
|
+
[TARGET AREA]
|
|
217
|
+
|
|
|
218
|
+
v
|
|
219
|
+
[files/services the target area depends on]
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Identify:
|
|
223
|
+
- **Direct dependents**: Files that import from the target area
|
|
224
|
+
- **Direct dependencies**: Files/services the target area imports or calls
|
|
225
|
+
- **Transitive risks**: Changes that could cascade (shared types, common utilities, database schema)
|
|
226
|
+
- **External dependencies**: Third-party libraries used in this area, with version info
|
|
227
|
+
|
|
228
|
+
Flag any circular dependencies discovered during this analysis.
|
|
229
|
+
|
|
230
|
+
### Step 8: Assess Test Coverage
|
|
231
|
+
|
|
232
|
+
Examine the test infrastructure:
|
|
233
|
+
|
|
234
|
+
- **Test framework**: Which runner? Configuration?
|
|
235
|
+
- **Test types present**: Unit? Integration? E2E? None?
|
|
236
|
+
- **Coverage**: If coverage tools are configured, check existing reports. If not, note the gap.
|
|
237
|
+
- **Test quality indicators**:
|
|
238
|
+
- Do tests use real assertions or just check "does not throw"?
|
|
239
|
+
- Are there integration tests that hit real services/databases or only mocks?
|
|
240
|
+
- Is there E2E coverage for critical paths?
|
|
241
|
+
- **Testing gaps in the target area**: List files or modules with no test coverage.
|
|
242
|
+
- **Test patterns**: How are tests structured? Setup/teardown patterns? Factory patterns? Fixture approach?
|
|
243
|
+
|
|
244
|
+
### Step 9: Flag Risks
|
|
245
|
+
|
|
246
|
+
Identify potential problems that could affect the planned changes:
|
|
247
|
+
|
|
248
|
+
| Risk Category | What to Look For |
|
|
249
|
+
|---|---|
|
|
250
|
+
| **Tight coupling** | God objects, circular imports, shared mutable state |
|
|
251
|
+
| **Missing tests** | Areas with zero coverage that will be modified |
|
|
252
|
+
| **Tech debt** | TODO comments, deprecated API usage, workarounds with explanatory comments |
|
|
253
|
+
| **Security concerns** | Hardcoded secrets, SQL concatenation, missing input validation |
|
|
254
|
+
| **Performance concerns** | N+1 queries, missing pagination, unbounded loops, no caching |
|
|
255
|
+
| **Fragile areas** | Files with high churn (many recent commits), merge conflict hotspots |
|
|
256
|
+
| **Stale dependencies** | Outdated packages with known vulnerabilities |
|
|
257
|
+
| **Missing documentation** | Complex logic with no comments or docs |
|
|
258
|
+
|
|
259
|
+
For each risk, rate severity:
|
|
260
|
+
|
|
261
|
+
- **High**: Will likely cause problems during this change
|
|
262
|
+
- **Medium**: Could cause problems, should be addressed
|
|
263
|
+
- **Low**: Worth noting but unlikely to affect current work
|
|
264
|
+
|
|
265
|
+
### Step 9.5: Codex Verify
|
|
266
|
+
|
|
267
|
+
Check the mode recorded at Step 1.5. If **Verify** was selected, dispatch Codex to review the analysis for structural gaps, missed risks, and mischaracterized patterns. Merge findings into a "Second Opinion" section of the report. If **Takeover** was selected, skip this step (Codex already ran the analysis). If **Skip**, do nothing. Do NOT re-run the consent flow. See **Codex Integration** section below for full details.
|
|
268
|
+
|
|
269
|
+
### Step 10: Write Analysis Report
|
|
270
|
+
|
|
271
|
+
Write the complete analysis to `.forge/work/{type}/{name}/codebase-analysis.md`.
|
|
272
|
+
|
|
273
|
+
The report MUST include these sections:
|
|
274
|
+
|
|
275
|
+
```markdown
|
|
276
|
+
# Codebase Analysis: {feature-name}
|
|
277
|
+
|
|
278
|
+
## Analysis Scope
|
|
279
|
+
{What was analyzed and why}
|
|
280
|
+
|
|
281
|
+
## Project Structure
|
|
282
|
+
{Directory tree with annotations}
|
|
283
|
+
|
|
284
|
+
## Technology Stack
|
|
285
|
+
{Table of technologies with versions}
|
|
286
|
+
|
|
287
|
+
## Code Patterns
|
|
288
|
+
### Architecture
|
|
289
|
+
{Architectural pattern with examples}
|
|
290
|
+
|
|
291
|
+
### API Style
|
|
292
|
+
{How APIs are built with examples}
|
|
293
|
+
|
|
294
|
+
### State Management
|
|
295
|
+
{How state is handled}
|
|
296
|
+
|
|
297
|
+
### Error Handling
|
|
298
|
+
{Error handling approach with examples}
|
|
299
|
+
|
|
300
|
+
### Data Validation
|
|
301
|
+
{Validation approach}
|
|
302
|
+
|
|
303
|
+
## Conventions to Follow
|
|
304
|
+
### Naming
|
|
305
|
+
{Naming conventions with examples}
|
|
306
|
+
|
|
307
|
+
### File Organization
|
|
308
|
+
{How files are organized}
|
|
309
|
+
|
|
310
|
+
### Import Style
|
|
311
|
+
{Import patterns}
|
|
312
|
+
|
|
313
|
+
### Code Style
|
|
314
|
+
{Linter/formatter settings, style patterns}
|
|
315
|
+
|
|
316
|
+
## Dependency Map
|
|
317
|
+
{Dependency diagram for the target area}
|
|
318
|
+
|
|
319
|
+
## Test Assessment
|
|
320
|
+
{Test infrastructure, coverage, gaps}
|
|
321
|
+
|
|
322
|
+
## Risks
|
|
323
|
+
{Categorized risk table with severity}
|
|
324
|
+
|
|
325
|
+
## Recommendations
|
|
326
|
+
{Suggestions for the upcoming work based on findings}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Step 11: Update Feature Manifest
|
|
330
|
+
|
|
331
|
+
After writing the report, update `.forge/work/{type}/{name}/manifest.yaml`:
|
|
332
|
+
|
|
333
|
+
```yaml
|
|
334
|
+
artifacts:
|
|
335
|
+
codebase-analysis:
|
|
336
|
+
path: codebase-analysis.md
|
|
337
|
+
status: complete
|
|
338
|
+
completed_at: YYYY-MM-DD
|
|
339
|
+
scope: targeted | full
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## Key Rules
|
|
345
|
+
|
|
346
|
+
1. **Read the actual code.** Do not guess patterns from file names alone. Open files, read implementations, cite specific examples.
|
|
347
|
+
2. **Follow existing patterns.** The analysis report tells future skills what conventions to follow. If the codebase uses snake_case, do not propose camelCase.
|
|
348
|
+
3. **Scope appropriately.** Full project analysis for greenfield-adjacent work. Targeted analysis for small changes. Do not spend 30 minutes analyzing a codebase for a one-line fix.
|
|
349
|
+
4. **Cite specific files.** Every pattern claim must reference at least one file as evidence. "The project uses Express" is weak. "The project uses Express -- see `src/api/routes/users.ts` line 15" is strong.
|
|
350
|
+
5. **Flag, do not fix.** This skill identifies problems. It does not solve them. Fixes happen during planning and implementation.
|
|
351
|
+
6. **Update for every feature.** Even if a codebase analysis exists from a prior feature, run a fresh targeted analysis for the new feature area. Codebases change.
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## Anti-Patterns
|
|
356
|
+
|
|
357
|
+
| Anti-Pattern | Why It Is Wrong | What To Do Instead |
|
|
358
|
+
|---|---|---|
|
|
359
|
+
| **Assuming patterns from the framework** | "It's React so they must use hooks" -- maybe they don't | Read the code. Verify. |
|
|
360
|
+
| **Skipping dependency tracing** | Changes cascade through imports you didn't check | Trace at least one level of dependencies |
|
|
361
|
+
| **Ignoring test gaps** | Untested code is unknown code | Flag missing coverage explicitly |
|
|
362
|
+
| **Over-analyzing stable areas** | Time spent on code that won't change is wasted | Focus on the area being modified plus its neighbors |
|
|
363
|
+
| **Listing tools without checking versions** | "Uses TypeScript" is less useful than "Uses TypeScript 5.3 with strict mode" | Check config files for version info |
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## Special Cases
|
|
368
|
+
|
|
369
|
+
### Monorepo Analysis
|
|
370
|
+
|
|
371
|
+
If the project is a monorepo:
|
|
372
|
+
1. Identify the package/workspace structure
|
|
373
|
+
2. Determine which package(s) will be affected
|
|
374
|
+
3. Map cross-package dependencies
|
|
375
|
+
4. Note shared tooling configuration
|
|
376
|
+
|
|
377
|
+
### No Existing Tests
|
|
378
|
+
|
|
379
|
+
If the project has no test infrastructure:
|
|
380
|
+
1. Note this as a HIGH risk
|
|
381
|
+
2. Identify the test runner the project would naturally use (based on stack)
|
|
382
|
+
3. Flag that test setup will be an extra task during planning
|
|
383
|
+
|
|
384
|
+
### Legacy Codebase
|
|
385
|
+
|
|
386
|
+
If the codebase has significant tech debt:
|
|
387
|
+
1. Separate "tech debt to address now" from "tech debt to leave alone"
|
|
388
|
+
2. Only flag debt that intersects with the planned changes
|
|
389
|
+
3. Suggest incremental improvements, not full rewrites
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## Graphify Context
|
|
394
|
+
**Protocol:** `protocols/graphify.md` | **Guard:** Step 2 of this skill's checklist.
|
|
395
|
+
|
|
396
|
+
**How graph data maps to this skill's output:**
|
|
397
|
+
- **God nodes** → list as critical components in Project Structure and Risks sections
|
|
398
|
+
- **Communities (top 20 by cohesion)** → map to subsystems / bounded contexts in Architecture section
|
|
399
|
+
- **EXTRACTED edges** → trusted, cite directly as dependencies in Dependency Map
|
|
400
|
+
- **INFERRED edges** → flag as hypotheses, verify against actual imports before reporting
|
|
401
|
+
- **AMBIGUOUS edges** → add to Risks section as investigation targets
|
|
402
|
+
|
|
403
|
+
**CLI queries** (if CLI available and graph exists):
|
|
404
|
+
- `graphify query "what are the main subsystems" --budget 2000 --graph graphify-out/graph.json`
|
|
405
|
+
- `graphify query "what are the cross-cutting concerns" --budget 1500 --graph graphify-out/graph.json`
|
|
406
|
+
- `graphify explain "<god node>" --graph graphify-out/graph.json` — for each god node
|
|
407
|
+
|
|
408
|
+
**Codex bridge:** Graph-enriched analysis feeds into the Codex verify step below. Pass god nodes, community boundaries, and edge confidence data as context.
|
|
409
|
+
|
|
410
|
+
---
|
|
411
|
+
|
|
412
|
+
## Codex Integration
|
|
413
|
+
**Modes:** Verify or Takeover | **Protocol:** `protocols/codex.md`
|
|
414
|
+
|
|
415
|
+
- **Verify:** Claude analyzes the codebase, Codex reviews for gaps.
|
|
416
|
+
- **Takeover:** Codex analyzes the codebase, Claude reviews the report.
|
|
417
|
+
|
|
418
|
+
**When:** After the architect subagent produces the codebase analysis report (enriched by graph context if available).
|
|
419
|
+
|
|
420
|
+
**Context to pass:**
|
|
421
|
+
- Path to `codebase-analysis.md`
|
|
422
|
+
- Path to source directories identified in the analysis
|
|
423
|
+
- Path to `graphify-out/graph.json` and `GRAPH_REPORT.md` (if present)
|
|
424
|
+
|
|
425
|
+
**What Codex reviews:**
|
|
426
|
+
- Structural gaps the analysis missed (unused exports, disconnected modules, dead code)
|
|
427
|
+
- Dependency risks not flagged (circular imports, version mismatches)
|
|
428
|
+
- Architecture patterns the analysis may have mischaracterized
|
|
429
|
+
|
|
430
|
+
**Prompt focus:** "Review this codebase analysis for structural gaps, missed risks, and mischaracterized patterns. Focus on what the analysis MISSED, not what it got right."
|
|
431
|
+
|
|
432
|
+
**Presentation:** Merge Codex findings into the analysis report under a "Second Opinion" section. Flag disagreements with Claude's assessment.
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
## Transition
|
|
437
|
+
|
|
438
|
+
After the analysis is complete:
|
|
439
|
+
|
|
440
|
+
> "Codebase analysis complete and written to `.forge/work/{type}/{name}/codebase-analysis.md`. Key findings:
|
|
441
|
+
>
|
|
442
|
+
> - **Architecture**: {one line summary}
|
|
443
|
+
> - **Conventions**: {key convention to follow}
|
|
444
|
+
> - **Risks**: {N} high, {N} medium, {N} low
|
|
445
|
+
>
|
|
446
|
+
> Ready to proceed to brainstorming. I'll use the plan-brainstorm skill to explore approaches, referencing the patterns and conventions identified here."
|
|
447
|
+
|
|
448
|
+
Invoke `plan-brainstorm` as the next step.
|