@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,301 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: build-pr-workflow
|
|
3
|
+
description: "Use when feature work needs branch isolation, atomic commits, or PR creation — covers the full git lifecycle from worktree to merge."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PR Workflow
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Manage the full git workflow lifecycle: create isolated workspaces, make atomic commits during development, and finish work with structured options for merge or PR creation.
|
|
11
|
+
|
|
12
|
+
**Announce at start:** "I'm using the build-pr-workflow skill to manage the git workflow."
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
- Starting any feature, bugfix, or refactor that needs branch isolation
|
|
17
|
+
- Creating pull requests from completed work
|
|
18
|
+
- Finishing a development branch (merge, PR, keep, or discard)
|
|
19
|
+
|
|
20
|
+
## When to load references
|
|
21
|
+
|
|
22
|
+
- **`references/worktree-setup.md`** — Phase 1 detail: directory selection priority, safety-verification gitignore check, step-by-step worktree creation. Load before starting a new branch.
|
|
23
|
+
- **`references/pr-template.md`** — Phase 3 detail: the full PR description template and the `gh pr create` HEREDOC. Load when ready to open the PR.
|
|
24
|
+
- **`references/subagent-merge.md`** — Protocol for integrating output from subagents dispatched with `isolation: "worktree"`. Load when a worktree-isolated subagent has returned.
|
|
25
|
+
|
|
26
|
+
## Phase 1: Worktree Creation
|
|
27
|
+
|
|
28
|
+
The detailed procedure (directory priority, gitignore safety, project setup, baseline verification) lives in **`references/worktree-setup.md`** — load it before starting a new worktree.
|
|
29
|
+
|
|
30
|
+
In summary:
|
|
31
|
+
|
|
32
|
+
1. Pick the worktree directory: `.worktrees/` (preferred) → `worktrees/` → CLAUDE.md preference → ask the user.
|
|
33
|
+
2. **Verify it's gitignored.** If not, add to `.gitignore` and commit before creating the worktree.
|
|
34
|
+
3. `git worktree add <path> -b <branch-name>` using the conventional branch prefix (`feat/`, `fix/`, `refactor/`, `hotfix/`).
|
|
35
|
+
4. Run project setup (npm install, pip install, cargo build, go mod download as appropriate).
|
|
36
|
+
5. Verify clean baseline by running the project's test command. If tests fail, report and ask.
|
|
37
|
+
|
|
38
|
+
## Phase 2: Development
|
|
39
|
+
|
|
40
|
+
### Commit Discipline
|
|
41
|
+
|
|
42
|
+
One commit per logical unit of work. Each commit must:
|
|
43
|
+
|
|
44
|
+
1. **Be atomic** — Contains exactly one logical change
|
|
45
|
+
2. **Pass all tests** — Never commit broken code
|
|
46
|
+
3. **Use conventional commits** — Format: `type(scope): description`
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
feat(auth): add JWT token validation middleware
|
|
50
|
+
fix(api): handle null email in user creation
|
|
51
|
+
refactor(db): extract connection pool configuration
|
|
52
|
+
test(auth): add integration tests for login flow
|
|
53
|
+
docs(api): update endpoint documentation
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Commit Workflow
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# 1. Verify tests pass before committing
|
|
60
|
+
npm test # or equivalent
|
|
61
|
+
|
|
62
|
+
# 2. Stage specific files (never git add .)
|
|
63
|
+
git add src/auth/middleware.ts tests/auth/middleware.test.ts
|
|
64
|
+
|
|
65
|
+
# 3. Commit with conventional message
|
|
66
|
+
git commit -m "feat(auth): add JWT token validation middleware"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Rules:**
|
|
70
|
+
- Run tests before every commit
|
|
71
|
+
- Stage specific files, not everything
|
|
72
|
+
- Never commit `.env`, secrets, or large binaries
|
|
73
|
+
- One logical change per commit, not "save my progress"
|
|
74
|
+
|
|
75
|
+
### Atomic Commit Splitting
|
|
76
|
+
|
|
77
|
+
When a changeset touches 3+ files, split into multiple atomic commits along logical boundaries:
|
|
78
|
+
|
|
79
|
+
| Files Changed | Minimum Commits |
|
|
80
|
+
|---|---|
|
|
81
|
+
| 3-4 files | 2+ commits |
|
|
82
|
+
| 5-9 files | 3+ commits |
|
|
83
|
+
| 10+ files | 5+ commits |
|
|
84
|
+
|
|
85
|
+
**Split along these boundaries:**
|
|
86
|
+
- Separate module/component boundaries
|
|
87
|
+
- Separate concern types (types, logic, tests, config)
|
|
88
|
+
- Each commit independently revertable without breaking the project
|
|
89
|
+
|
|
90
|
+
**Before splitting:** Analyze the last 30 commits to detect the project's commit style. If mixed styles, conventional commits take precedence when ≥50% of commits use them. If the repo has fewer than 30 commits or no clear majority, default to conventional commits per git-workflow.md.
|
|
91
|
+
|
|
92
|
+
### During TDD Cycles
|
|
93
|
+
|
|
94
|
+
A natural commit rhythm during TDD:
|
|
95
|
+
|
|
96
|
+
1. RED-GREEN-REFACTOR cycle for behavior A -> commit
|
|
97
|
+
2. RED-GREEN-REFACTOR cycle for behavior B -> commit
|
|
98
|
+
3. RED-GREEN-REFACTOR cycle for behavior C -> commit
|
|
99
|
+
|
|
100
|
+
Each commit captures one complete TDD cycle. The commit message describes the behavior added, not the test written.
|
|
101
|
+
|
|
102
|
+
## Phase 3: PR Creation
|
|
103
|
+
|
|
104
|
+
### PR-Per-Function Strategy
|
|
105
|
+
|
|
106
|
+
Each PR should cover one logical function or component. This means:
|
|
107
|
+
|
|
108
|
+
- **One PR per API endpoint** (e.g., "Add POST /api/users endpoint")
|
|
109
|
+
- **One PR per UI component** (e.g., "Add UserProfileCard component")
|
|
110
|
+
- **One PR per service** (e.g., "Add email notification service")
|
|
111
|
+
- **One PR per migration** (e.g., "Add users table migration")
|
|
112
|
+
|
|
113
|
+
**Not one giant PR** with everything. Not one PR per file either. One PR per logical unit that can be reviewed, tested, and merged independently.
|
|
114
|
+
|
|
115
|
+
### PR Requirements
|
|
116
|
+
|
|
117
|
+
Each PR must be:
|
|
118
|
+
|
|
119
|
+
1. **Independently mergeable** — Does not break anything if merged alone
|
|
120
|
+
2. **Independently testable** — Has its own tests that pass
|
|
121
|
+
3. **Properly described** — Links to feature manifest and requirements
|
|
122
|
+
4. **Small enough to review** — Under 400 lines of diff is ideal
|
|
123
|
+
|
|
124
|
+
### Creating the PR
|
|
125
|
+
|
|
126
|
+
The full template and HEREDOC live in **`references/pr-template.md`** — load it when you're ready to open the PR. The required sections are: Summary, Feature Manifest, Requirements Traceability, Changes, Test Plan, Checklist.
|
|
127
|
+
|
|
128
|
+
## Phase 4: Finishing
|
|
129
|
+
|
|
130
|
+
### Step 1: Verify Tests
|
|
131
|
+
|
|
132
|
+
**Before presenting options, verify tests pass:**
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npm test / pytest / cargo test / go test ./...
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**If tests fail:**
|
|
139
|
+
```
|
|
140
|
+
Tests failing (<N> failures). Must fix before completing:
|
|
141
|
+
|
|
142
|
+
[Show failures]
|
|
143
|
+
|
|
144
|
+
Cannot proceed with merge/PR until tests pass.
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Stop. Do not proceed.
|
|
148
|
+
|
|
149
|
+
**If tests pass:** Continue.
|
|
150
|
+
|
|
151
|
+
### Step 2: Determine Base Branch
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Try common base branches
|
|
155
|
+
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Or ask: "This branch split from main -- is that correct?"
|
|
159
|
+
|
|
160
|
+
### Step 3: Present Options
|
|
161
|
+
|
|
162
|
+
Present exactly these 4 options:
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
Implementation complete. What would you like to do?
|
|
166
|
+
|
|
167
|
+
1. Merge back to <base-branch> locally
|
|
168
|
+
2. Push and create a Pull Request
|
|
169
|
+
3. Keep the branch as-is (I'll handle it later)
|
|
170
|
+
4. Discard this work
|
|
171
|
+
|
|
172
|
+
Which option?
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Keep options concise. Do not add lengthy explanations.
|
|
176
|
+
|
|
177
|
+
### Step 4: Execute Choice
|
|
178
|
+
|
|
179
|
+
#### Option 1: Merge Locally
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Switch to base branch
|
|
183
|
+
git checkout <base-branch>
|
|
184
|
+
|
|
185
|
+
# Pull latest
|
|
186
|
+
git pull
|
|
187
|
+
|
|
188
|
+
# Merge feature branch
|
|
189
|
+
git merge <feature-branch>
|
|
190
|
+
|
|
191
|
+
# Verify tests on merged result
|
|
192
|
+
npm test
|
|
193
|
+
|
|
194
|
+
# If tests pass, delete feature branch
|
|
195
|
+
git branch -d <feature-branch>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Then: Clean up worktree (Step 5).
|
|
199
|
+
|
|
200
|
+
#### Option 2: Push and Create PR
|
|
201
|
+
|
|
202
|
+
Follow **`references/pr-template.md`** for the structured body. Push, create the PR, report the URL. Then: Clean up worktree (Step 5).
|
|
203
|
+
|
|
204
|
+
#### Option 3: Keep As-Is
|
|
205
|
+
|
|
206
|
+
Report: "Keeping branch `<name>`. Worktree preserved at `<path>`."
|
|
207
|
+
|
|
208
|
+
**Do not clean up worktree.**
|
|
209
|
+
|
|
210
|
+
#### Option 4: Discard
|
|
211
|
+
|
|
212
|
+
**Confirm first:**
|
|
213
|
+
```
|
|
214
|
+
This will permanently delete:
|
|
215
|
+
- Branch <name>
|
|
216
|
+
- All commits on this branch
|
|
217
|
+
- Worktree at <path>
|
|
218
|
+
|
|
219
|
+
Type 'discard' to confirm.
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Wait for exact confirmation. If confirmed:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
git checkout <base-branch>
|
|
226
|
+
git branch -D <feature-branch>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Then: Clean up worktree (Step 5).
|
|
230
|
+
|
|
231
|
+
### Step 5: Worktree Cleanup
|
|
232
|
+
|
|
233
|
+
**For Options 1, 2, 4:**
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# Check if working in a worktree
|
|
237
|
+
git worktree list | grep <feature-branch>
|
|
238
|
+
|
|
239
|
+
# If yes, remove it
|
|
240
|
+
git worktree remove <worktree-path>
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**For Option 3:** Keep worktree intact.
|
|
244
|
+
|
|
245
|
+
## Merging Subagent Worktree Output
|
|
246
|
+
|
|
247
|
+
When dispatching subagents with `isolation: "worktree"`, follow the protocol in **`references/subagent-merge.md`** — it covers: requiring the subagent to commit, verifying commits before merging, merging via `git merge --no-ff` (never `cp`), and worktree cleanup.
|
|
248
|
+
|
|
249
|
+
## Quick Reference
|
|
250
|
+
|
|
251
|
+
### Worktree Selection
|
|
252
|
+
|
|
253
|
+
| Situation | Action |
|
|
254
|
+
|-----------|--------|
|
|
255
|
+
| `.worktrees/` exists | Use it (verify ignored) |
|
|
256
|
+
| `worktrees/` exists | Use it (verify ignored) |
|
|
257
|
+
| Both exist | Use `.worktrees/` |
|
|
258
|
+
| Neither exists | Check CLAUDE.md, then ask user |
|
|
259
|
+
| Directory not ignored | Add to .gitignore + commit first |
|
|
260
|
+
| Tests fail during baseline | Report failures + ask |
|
|
261
|
+
|
|
262
|
+
### Finishing Options
|
|
263
|
+
|
|
264
|
+
| Option | Merge | Push | Keep Worktree | Delete Branch |
|
|
265
|
+
|--------|-------|------|---------------|---------------|
|
|
266
|
+
| 1. Merge locally | Yes | No | No | Yes (safe) |
|
|
267
|
+
| 2. Create PR | No | Yes | Cleaned up | No |
|
|
268
|
+
| 3. Keep as-is | No | No | Yes | No |
|
|
269
|
+
| 4. Discard | No | No | No | Yes (force) |
|
|
270
|
+
|
|
271
|
+
## Red Flags
|
|
272
|
+
|
|
273
|
+
**Never:**
|
|
274
|
+
- Create a worktree without verifying it is ignored (project-local) — pollutes git status with worktree contents.
|
|
275
|
+
- Commit without running tests — breaks bisection and blocks other developers.
|
|
276
|
+
- Proceed with failing tests, force-push without request, or skip the typed "discard" confirmation.
|
|
277
|
+
- Create a PR without a structured description linking to the feature manifest.
|
|
278
|
+
|
|
279
|
+
## I/O Contract
|
|
280
|
+
|
|
281
|
+
| Field | Value |
|
|
282
|
+
|---|---|
|
|
283
|
+
| **Requires** | Task scope from manifest's `slice_graph` (prototype-driven flow, produced by `harden`) OR `.forge/work/{type}/{name}/tasks.md` (non-prototype fallback, produced by `plan-task-decompose`); work manifest at `.forge/work/{type}/{name}/manifest.yaml` |
|
|
284
|
+
| **Produces** | Git worktree, feature branch, atomic commits, pull request(s) on GitHub/GitLab |
|
|
285
|
+
| **Feeds into** | `deliver-deploy` (PRs ready to merge and deploy) |
|
|
286
|
+
| **Updates manifest** | `branch`, `worktree`, `phase`, PRs created |
|
|
287
|
+
|
|
288
|
+
## Integration
|
|
289
|
+
|
|
290
|
+
**Called by:**
|
|
291
|
+
- `/feature` command (worktree setup + PR creation)
|
|
292
|
+
- `/greenfield` command (worktree setup + PR creation)
|
|
293
|
+
- `/bugfix` command (branch + PR)
|
|
294
|
+
- `/refactor` command (branch + PR)
|
|
295
|
+
|
|
296
|
+
**Pairs with:**
|
|
297
|
+
- `build-tdd` (commits happen during TDD cycles at Phase 6)
|
|
298
|
+
- `quality-code-review` (reviews happen before PR creation)
|
|
299
|
+
- `harden` (prototype-driven flow: slice graph determines PR scope)
|
|
300
|
+
- `plan-task-decompose` (non-prototype fallback flow: tasks determine PR scope)
|
|
301
|
+
- `deliver-deploy` (PRs feed into deployment)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# PR creation — template and command
|
|
2
|
+
|
|
3
|
+
Phase 3 of the PR workflow: push the branch and create a PR with a structured description. Load this when ready to open the PR.
|
|
4
|
+
|
|
5
|
+
## Required sections in the PR description
|
|
6
|
+
|
|
7
|
+
| Section | Required | Purpose |
|
|
8
|
+
|---------|----------|---------|
|
|
9
|
+
| Summary | Yes | What and why in 2-3 bullets |
|
|
10
|
+
| Feature Manifest | Yes | Link to manifest for traceability |
|
|
11
|
+
| Requirements Traceability | Yes | Which requirements this PR satisfies |
|
|
12
|
+
| Changes | Yes | Key files changed with brief description |
|
|
13
|
+
| Test Plan | Yes | How to verify the PR works |
|
|
14
|
+
| Checklist | Yes | Verification items |
|
|
15
|
+
|
|
16
|
+
## Creating the PR
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# 1. Verify all tests pass
|
|
20
|
+
npm test
|
|
21
|
+
|
|
22
|
+
# 2. Push branch
|
|
23
|
+
git push -u origin <branch-name>
|
|
24
|
+
|
|
25
|
+
# 3. Create PR with structured description
|
|
26
|
+
gh pr create --title "<type>(scope): description" --body "$(cat <<'PREOF'
|
|
27
|
+
## Summary
|
|
28
|
+
|
|
29
|
+
- What this PR does (2-3 bullets)
|
|
30
|
+
- Why it is needed
|
|
31
|
+
|
|
32
|
+
## Feature Manifest
|
|
33
|
+
|
|
34
|
+
Links to: `.forge/work/{type}/{name}/manifest.yaml` (manifest), slice IDs from `slice_graph` (prototype-driven flow) OR REQ-IDs (non-prototype fallback flow).
|
|
35
|
+
|
|
36
|
+
## Requirements Traceability
|
|
37
|
+
|
|
38
|
+
- Implements: [REQ-001] User can create account
|
|
39
|
+
- Satisfies acceptance criteria: [AC-001.1], [AC-001.2]
|
|
40
|
+
|
|
41
|
+
## Changes
|
|
42
|
+
|
|
43
|
+
- `src/auth/service.ts` -- New authentication service
|
|
44
|
+
- `src/auth/middleware.ts` -- JWT validation middleware
|
|
45
|
+
- `tests/auth/` -- Unit and integration tests
|
|
46
|
+
|
|
47
|
+
## Test Plan
|
|
48
|
+
|
|
49
|
+
- [ ] Unit tests pass (`npm test`)
|
|
50
|
+
- [ ] Integration tests pass
|
|
51
|
+
- [ ] Manual verification: [describe steps]
|
|
52
|
+
|
|
53
|
+
## Checklist
|
|
54
|
+
|
|
55
|
+
- [ ] Tests written and passing
|
|
56
|
+
- [ ] No skipped tests
|
|
57
|
+
- [ ] API contract validated
|
|
58
|
+
- [ ] No secrets in code
|
|
59
|
+
- [ ] Conventional commit messages
|
|
60
|
+
PREOF
|
|
61
|
+
)"
|
|
62
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Merging subagent worktree output
|
|
2
|
+
|
|
3
|
+
When the main agent dispatches subagents with `isolation: "worktree"`, the subagent works in an isolated git worktree. The worktree path and branch name are returned when the subagent completes. Follow this protocol to integrate the work.
|
|
4
|
+
|
|
5
|
+
Load this when a subagent dispatched with worktree isolation has returned.
|
|
6
|
+
|
|
7
|
+
## Dispatch
|
|
8
|
+
|
|
9
|
+
Include in the subagent prompt: **"Commit your changes with a conventional commit message before completing."**
|
|
10
|
+
|
|
11
|
+
## Post-return integration
|
|
12
|
+
|
|
13
|
+
After a subagent completes:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# 1. Check if the subagent committed
|
|
17
|
+
cd <worktree-path>
|
|
18
|
+
git log --oneline <worktree-branch> --not main | head -5
|
|
19
|
+
|
|
20
|
+
# 2. If no commits exist, commit on the subagent's behalf
|
|
21
|
+
# Review changed files first, then stage specifically (avoid staging secrets/artifacts)
|
|
22
|
+
git add <changed-source-files>
|
|
23
|
+
git commit -m "feat(scope): description of subagent work"
|
|
24
|
+
|
|
25
|
+
# 3. Return to main working directory
|
|
26
|
+
cd <main-repo-path>
|
|
27
|
+
|
|
28
|
+
# 4. Merge via git — NEVER use cp/file copy
|
|
29
|
+
git merge <worktree-branch> --no-ff
|
|
30
|
+
|
|
31
|
+
# 5. If merge conflicts arise, resolve them manually
|
|
32
|
+
# This is expected when parallel agents touch shared files
|
|
33
|
+
|
|
34
|
+
# 6. Clean up the worktree
|
|
35
|
+
git worktree remove <worktree-path>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Rules
|
|
39
|
+
|
|
40
|
+
- **NEVER** merge subagent work via `cp` or file copy — use `git merge --no-ff`
|
|
41
|
+
- **ALWAYS** verify the subagent committed before merging — commit on their behalf if they didn't
|
|
42
|
+
- **`--no-ff`** preserves the branch in history, making it clear which work came from which subagent
|
|
43
|
+
- If merge conflicts arise, this is a signal that the tasks were too tightly coupled — resolve the conflict, then note it as a gotcha for future task decomposition
|
|
44
|
+
|
|
45
|
+
## Why not cp
|
|
46
|
+
|
|
47
|
+
File copy (`cp`) silently overwrites. If two parallel subagents both modified the same file, `cp` from the second agent destroys the first agent's work with no warning. `git merge` surfaces these conflicts explicitly.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Worktree setup — directory selection and creation
|
|
2
|
+
|
|
3
|
+
Phase 1 of the PR workflow: pick a worktree directory, verify it's gitignored, create the worktree, install deps, verify the baseline. Load this when starting a new feature/bugfix/refactor that needs an isolated worktree.
|
|
4
|
+
|
|
5
|
+
## Directory selection process
|
|
6
|
+
|
|
7
|
+
Follow this priority order:
|
|
8
|
+
|
|
9
|
+
### 1. Check existing directories
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Check in priority order
|
|
13
|
+
ls -d .worktrees 2>/dev/null # Preferred (hidden)
|
|
14
|
+
ls -d worktrees 2>/dev/null # Alternative
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**If found:** Use that directory. If both exist, `.worktrees` wins.
|
|
18
|
+
|
|
19
|
+
### 2. Check CLAUDE.md
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
grep -i "worktree.*director" CLAUDE.md 2>/dev/null
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**If preference specified:** Use it without asking.
|
|
26
|
+
|
|
27
|
+
### 3. Ask user
|
|
28
|
+
|
|
29
|
+
If no directory exists and no CLAUDE.md preference:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
No worktree directory found. Where should I create worktrees?
|
|
33
|
+
|
|
34
|
+
1. .worktrees/ (project-local, hidden)
|
|
35
|
+
2. worktrees/ (project-local, visible)
|
|
36
|
+
3. Custom path
|
|
37
|
+
|
|
38
|
+
Which would you prefer?
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Safety verification
|
|
42
|
+
|
|
43
|
+
**MUST verify directory is ignored before creating worktree:**
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Check if directory is ignored (respects local, global, and system gitignore)
|
|
47
|
+
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**If NOT ignored:**
|
|
51
|
+
|
|
52
|
+
Fix immediately:
|
|
53
|
+
1. Add appropriate line to `.gitignore`
|
|
54
|
+
2. Commit the change
|
|
55
|
+
3. Proceed with worktree creation
|
|
56
|
+
|
|
57
|
+
**Why critical:** Prevents accidentally committing worktree contents to the repository.
|
|
58
|
+
|
|
59
|
+
## Creation steps
|
|
60
|
+
|
|
61
|
+
### 1. Detect project and branch name
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
project=$(basename "$(git rev-parse --show-toplevel)")
|
|
65
|
+
# Branch name from feature manifest or task
|
|
66
|
+
branch_name="feat/feature-name" # or fix/, refactor/ per git-workflow rules
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Branch naming convention:**
|
|
70
|
+
- Features: `feat/short-description`
|
|
71
|
+
- Bug fixes: `fix/short-description`
|
|
72
|
+
- Refactors: `refactor/short-description`
|
|
73
|
+
- Hotfixes: `hotfix/short-description`
|
|
74
|
+
|
|
75
|
+
### 2. Create worktree
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Determine full path
|
|
79
|
+
path=".worktrees/$branch_name"
|
|
80
|
+
|
|
81
|
+
# Create worktree with new branch
|
|
82
|
+
git worktree add "$path" -b "$branch_name"
|
|
83
|
+
cd "$path"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 3. Run project setup
|
|
87
|
+
|
|
88
|
+
Auto-detect and run appropriate setup:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Node.js
|
|
92
|
+
if [ -f package.json ]; then npm install; fi
|
|
93
|
+
|
|
94
|
+
# Python
|
|
95
|
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
96
|
+
if [ -f pyproject.toml ]; then pip install -e ".[dev]" || poetry install; fi
|
|
97
|
+
|
|
98
|
+
# Rust
|
|
99
|
+
if [ -f Cargo.toml ]; then cargo build; fi
|
|
100
|
+
|
|
101
|
+
# Go
|
|
102
|
+
if [ -f go.mod ]; then go mod download; fi
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 4. Verify clean baseline
|
|
106
|
+
|
|
107
|
+
Run tests to ensure the worktree starts clean:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# Use project-appropriate command
|
|
111
|
+
npm test / pytest / cargo test / go test ./...
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**If tests fail:** Report failures, ask whether to proceed or investigate.
|
|
115
|
+
|
|
116
|
+
**If tests pass:** Report ready.
|
|
117
|
+
|
|
118
|
+
### 5. Report
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
Worktree ready at <full-path>
|
|
122
|
+
Branch: <branch-name>
|
|
123
|
+
Tests passing (<N> tests, 0 failures)
|
|
124
|
+
Ready to implement <feature-name>
|
|
125
|
+
```
|