@skyf0xx/hedgehog 0.1.17 → 0.1.19
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/README.md +18 -1
- package/bin/cli.mjs +61 -1
- package/package.json +1 -1
- package/src/agents/backend-eng.md +101 -0
- package/src/agents/bootstrap.md +1 -1
- package/src/agents/{ui-builder.md → front-end-eng.md} +13 -7
- package/src/agents/reviewer.md +6 -6
- package/src/agents/ux-planner.md +8 -8
- package/src/skills/hedgehog-loop/SKILL.md +17 -11
- package/src/skills/link-workspace-packages/SKILL.md +41 -0
- package/src/skills/nx-generate/SKILL.md +168 -0
- package/src/skills/nx-run-tasks/SKILL.md +56 -0
- package/src/skills/nx-workspace/SKILL.md +286 -0
- package/src/skills/nx-workspace/references/AFFECTED.md +27 -0
- package/src/templates/CLAUDE.md +9 -4
package/README.md
CHANGED
|
@@ -96,6 +96,17 @@ only runs whichever add-ons planning intake determined your project needs.
|
|
|
96
96
|
|
|
97
97
|
Or paste the repo URL to your Agent and have it install for you.
|
|
98
98
|
|
|
99
|
+
On a project that's already installed Hedgehog, pick up agent/skill
|
|
100
|
+
changes from a newer release with:
|
|
101
|
+
|
|
102
|
+
``` bash
|
|
103
|
+
npx @skyf0xx/hedgehog update
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This refreshes `.claude/agents/` and `.claude/skills/` only — it never
|
|
107
|
+
touches `CLAUDE.md`, `TODO.md`, the golden-core workspace, or
|
|
108
|
+
`skills/BMAD`, since those carry project-specific or write-once content.
|
|
109
|
+
|
|
99
110
|
## For Builders
|
|
100
111
|
|
|
101
112
|
Hedgehog brings proven software engineering practices into AI-assisted development.
|
|
@@ -148,7 +159,7 @@ Hedgehog runs BMAD for planning, then enforces the build that follows with tooli
|
|
|
148
159
|
|
|
149
160
|
| | Superpowers | BMAD | Hedgehog + BMAD |
|
|
150
161
|
| --- | --- | --- | --- |
|
|
151
|
-
| **What it is** | A skills library: brainstorm, plan, TDD, debug, review | A multi-agent planning framework: PM, Architect, Dev, QA personas | BMAD planning (brief → PRD →
|
|
162
|
+
| **What it is** | A skills library: brainstorm, plan, TDD, debug, review | A multi-agent planning framework: PM, Architect, Dev, QA personas | BMAD planning (brief → PRD → docs) → feeding a fixed-stack, enforced-order build |
|
|
152
163
|
| **Order comes from** | Skill instructions the agent is told to follow | Sequenced documents (brief → PRD → architecture → stories) | Tooling (Nx, lefthook, phase gate) |
|
|
153
164
|
| **Enforcement mechanism** | None. Prompted convention | None. One optional checklist between phases | Execution mechanically enforced |
|
|
154
165
|
| **Unit of work** | A task, planned in worktree-isolated steps | A story, derived from PRD and architecture docs | A module layer (schema → contract → repo → service → controller → UI) |
|
|
@@ -162,6 +173,12 @@ Hedgehog runs BMAD for planning, then enforces the build that follows with tooli
|
|
|
162
173
|
Planning intake runs on [BMAD-METHOD](https://github.com/bmad-code-org/BMAD-METHOD)
|
|
163
174
|
(`bmad-code-org/BMAD-METHOD`) MIT-licensed.
|
|
164
175
|
|
|
176
|
+
The `nx-generate`, `nx-run-tasks`, `nx-workspace`, and
|
|
177
|
+
`link-workspace-packages` skills are adapted from
|
|
178
|
+
[nx-ai-agents-config](https://github.com/nrwl/nx-ai-agents-config)
|
|
179
|
+
(`nrwl/nx-ai-agents-config`) MIT-licensed, pinned to commit `9609810`
|
|
180
|
+
(2026-07-23) and rewritten for Hedgehog's pnpm-only workspace convention.
|
|
181
|
+
|
|
165
182
|
## Support Hedgehog
|
|
166
183
|
|
|
167
184
|
If Hedgehog helps you build better AI software, consider giving it a ⭐ on GitHub.
|
package/bin/cli.mjs
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
// Usage:
|
|
6
6
|
// npx @skyf0xx/hedgehog init scaffold into the current directory
|
|
7
7
|
// npx @skyf0xx/hedgehog init --force overwrite files that already exist
|
|
8
|
+
// npx @skyf0xx/hedgehog update refresh .claude/agents + .claude/skills
|
|
8
9
|
// npx @skyf0xx/hedgehog --help
|
|
9
10
|
|
|
10
|
-
import { cp, mkdir, access, readdir, stat } from 'node:fs/promises';
|
|
11
|
+
import { cp, mkdir, access, readdir, stat, rm } from 'node:fs/promises';
|
|
11
12
|
import { constants } from 'node:fs';
|
|
12
13
|
import { fileURLToPath } from 'node:url';
|
|
13
14
|
import { dirname, join, relative, resolve } from 'node:path';
|
|
@@ -51,6 +52,19 @@ const PLAN = [
|
|
|
51
52
|
{ type: 'dir', from: 'src/golden-core', to: '.' },
|
|
52
53
|
];
|
|
53
54
|
|
|
55
|
+
// The subset of PLAN that's the discipline's payload rather than
|
|
56
|
+
// project-specific or write-once content: `update` re-copies exactly
|
|
57
|
+
// this, always overwriting, since a consuming project's own
|
|
58
|
+
// .claude/agents and .claude/skills are supposed to match upstream
|
|
59
|
+
// verbatim. CLAUDE.md/TODO.md carry project-filled content, golden-core
|
|
60
|
+
// is verified once by hedgehog-bootstrap-core, and skills/BMAD is
|
|
61
|
+
// re-vendored only deliberately (bmad-revendor) — none of those belong
|
|
62
|
+
// in an update.
|
|
63
|
+
const UPDATE_PLAN = [
|
|
64
|
+
{ type: 'dir', from: 'src/agents', to: '.claude/agents' },
|
|
65
|
+
{ type: 'dir', from: 'src/skills', to: '.claude/skills' },
|
|
66
|
+
];
|
|
67
|
+
|
|
54
68
|
const exists = (p) =>
|
|
55
69
|
access(p, constants.F_OK).then(
|
|
56
70
|
() => true,
|
|
@@ -89,10 +103,18 @@ committed alongside your code.
|
|
|
89
103
|
${bold('Usage')}
|
|
90
104
|
npx @skyf0xx/hedgehog init scaffold into the current directory
|
|
91
105
|
npx @skyf0xx/hedgehog init --force overwrite existing files
|
|
106
|
+
npx @skyf0xx/hedgehog update refresh .claude/agents + .claude/skills
|
|
92
107
|
npx @skyf0xx/hedgehog --help
|
|
93
108
|
|
|
94
109
|
After it runs, commit the .claude/ payload, open Claude Code, and say
|
|
95
110
|
"bootstrap this project" to trigger the hedgehog-bootstrap skill.
|
|
111
|
+
|
|
112
|
+
${bold('update')} re-copies only .claude/agents and .claude/skills from the
|
|
113
|
+
installed Hedgehog version, so an already-bootstrapped project can pick up
|
|
114
|
+
agent/skill changes from a newer release. It always overwrites those two
|
|
115
|
+
directories and never touches CLAUDE.md, TODO.md, golden-core, or
|
|
116
|
+
skills/BMAD — those are project-specific or updated deliberately, not by
|
|
117
|
+
this command.
|
|
96
118
|
`);
|
|
97
119
|
}
|
|
98
120
|
|
|
@@ -156,6 +178,39 @@ async function init({ force }) {
|
|
|
156
178
|
);
|
|
157
179
|
}
|
|
158
180
|
|
|
181
|
+
async function update() {
|
|
182
|
+
// Full replace, not a merge: clear each destination dir first so a
|
|
183
|
+
// rename or removal upstream (e.g. an agent renamed between releases)
|
|
184
|
+
// doesn't leave a stale file sitting alongside the new one.
|
|
185
|
+
for (const entry of UPDATE_PLAN) {
|
|
186
|
+
await rm(join(DEST_ROOT, entry.to), { recursive: true, force: true });
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
let written = 0;
|
|
190
|
+
for (const entry of UPDATE_PLAN) {
|
|
191
|
+
const files = await plannedFiles(entry);
|
|
192
|
+
for (const f of files) {
|
|
193
|
+
await mkdir(dirname(f.dest), { recursive: true });
|
|
194
|
+
await cp(f.src, f.dest);
|
|
195
|
+
written++;
|
|
196
|
+
console.log(` ${green('update')} ${relative(DEST_ROOT, f.dest)}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
console.log(
|
|
201
|
+
`\n${green(bold('Hedgehog agents/skills updated.'))} ${dim(`${written} files written`)}\n`,
|
|
202
|
+
);
|
|
203
|
+
console.log('Next steps:');
|
|
204
|
+
console.log(` 1. ${bold('git diff .claude/')} to review what changed`);
|
|
205
|
+
console.log(` 2. ${bold('git add -A && git commit -m "chore: update hedgehog"')}\n`);
|
|
206
|
+
console.log(
|
|
207
|
+
dim(
|
|
208
|
+
'CLAUDE.md, TODO.md, the golden-core workspace, and skills/BMAD are\n' +
|
|
209
|
+
'untouched — those carry project-specific or write-once content.',
|
|
210
|
+
),
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
159
214
|
async function main() {
|
|
160
215
|
const args = process.argv.slice(2);
|
|
161
216
|
if (args.includes('--help') || args.includes('-h') || args.length === 0) {
|
|
@@ -170,6 +225,11 @@ async function main() {
|
|
|
170
225
|
return;
|
|
171
226
|
}
|
|
172
227
|
|
|
228
|
+
if (cmd === 'update') {
|
|
229
|
+
await update();
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
173
233
|
console.error(`${red('Unknown command:')} ${cmd}\n`);
|
|
174
234
|
help();
|
|
175
235
|
process.exitCode = 1;
|
package/package.json
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: backend-eng
|
|
3
|
+
description: Use for the schema, contract, repository, service, controller, and queue steps of Phase A, once a module is in scope and its dependencies are built. Specializes in the Hedgehog stack's backend layer — Drizzle, Zod/ts-rest, NestJS, BullMQ (if the Queue add-on is on).
|
|
4
|
+
model: sonnet
|
|
5
|
+
color: red
|
|
6
|
+
tools: Read, Glob, Grep, Edit, Write, Bash
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
You are the backend-eng role in the Hedgehog discipline, building Phase A
|
|
10
|
+
(`packages/db`, `packages/contracts`, `libs/<module>/*`, `apps/api`,
|
|
11
|
+
`apps/worker`) one domain module at a time. The stack and the step
|
|
12
|
+
sequence within a module are fixed (`hedgehog-loop`) — not yours to
|
|
13
|
+
reorder or reshape; your job is executing schema → contract →
|
|
14
|
+
repository → service → controller (→ queue) correctly for the module
|
|
15
|
+
handed to you, one step at a time, gated before the next starts.
|
|
16
|
+
|
|
17
|
+
## Stack (locked)
|
|
18
|
+
|
|
19
|
+
- **Drizzle + drizzle-zod** for schema — the source of truth for a
|
|
20
|
+
module's shape. Types before data.
|
|
21
|
+
- **Zod + ts-rest** for the contract — the boundary. Generated from the
|
|
22
|
+
schema via `drizzle-zod`, not hand-duplicated.
|
|
23
|
+
- **NestJS** for the repository (port + Drizzle adapter), service (domain
|
|
24
|
+
logic, imports only ports), and controller (thin HTTP, wires the
|
|
25
|
+
contract to the service).
|
|
26
|
+
- **BullMQ**, port + adapter shape, for the queue step — only if the
|
|
27
|
+
Queue add-on is on for this project (`TODO.md`'s `## Add-ons` block)
|
|
28
|
+
and the operation genuinely needs async (long-running, retries,
|
|
29
|
+
fan-out).
|
|
30
|
+
- **PostgreSQL** via Docker Compose — never a natively-installed Postgres.
|
|
31
|
+
|
|
32
|
+
Use the `nx-run-tasks` skill to run build/lint/test/typecheck, `nx-workspace`
|
|
33
|
+
to inspect project/target config when a task fails or a boundary is
|
|
34
|
+
unclear, `nx-generate` if a step calls for scaffolding a new
|
|
35
|
+
library/app rather than hand-writing it, and `link-workspace-packages`
|
|
36
|
+
when a new package needs wiring into a consumer's dependencies.
|
|
37
|
+
|
|
38
|
+
## Core Responsibilities
|
|
39
|
+
|
|
40
|
+
- **Step 1 (schema)**: define the table in `packages/db` (Drizzle). One
|
|
41
|
+
domain module = one table. Cross-module references are FK-by-ID
|
|
42
|
+
columns only — never a foreign schema import.
|
|
43
|
+
- **Step 2 (contract)**: derive the Zod schema from Drizzle
|
|
44
|
+
(`drizzle-zod`) and wire the ts-rest contract in `packages/contracts`.
|
|
45
|
+
- **Step 3 (repository)**: a port (interface) plus a Drizzle adapter in
|
|
46
|
+
`libs/<module>/repository`. A `findById`-shaped miss returns
|
|
47
|
+
`undefined` — plain absence, not a thrown error; the service decides
|
|
48
|
+
what absence means.
|
|
49
|
+
- **Step 4 (service)**: domain logic in `libs/<module>/service`, importing
|
|
50
|
+
only its own ports (`type:port`, `type:util` — the Nx boundary rule).
|
|
51
|
+
Throws typed, domain-named errors (`OrderNotFoundError`, not a bare
|
|
52
|
+
`Error` or an HTTP exception). No logging, no HTTP, no queue mechanics
|
|
53
|
+
inside a service method. Multi-write operations wrap in one Drizzle
|
|
54
|
+
transaction, passed through the port.
|
|
55
|
+
- **Step 5 (controller)**: thin HTTP in `apps/api`, wiring the contract to
|
|
56
|
+
the service. The only layer that maps domain errors to status codes.
|
|
57
|
+
Validation happens once, at this boundary, via the Zod contract — past
|
|
58
|
+
it, types are trusted.
|
|
59
|
+
- **Step 5a (queue, conditional)**: a port + BullMQ adapter in
|
|
60
|
+
`apps/worker`, same shape as the repository — only when the Queue
|
|
61
|
+
add-on is on and this operation needs it.
|
|
62
|
+
|
|
63
|
+
## Workflow
|
|
64
|
+
|
|
65
|
+
1. Confirm the module is in scope (per `planner`'s scope boundary) and,
|
|
66
|
+
for any step past schema, that the step before it compiled and passed
|
|
67
|
+
tests. Cross-module FK targets should already have their own schema
|
|
68
|
+
landed — check before writing the FK column.
|
|
69
|
+
2. Build exactly one step. Commit using the exact Conventional Commit
|
|
70
|
+
format from `hedgehog-loop`
|
|
71
|
+
(`feat(<module>): schema` / `contract` / `repository` / `service` /
|
|
72
|
+
`api` / `queue`) once it typechecks, lints, and passes tests.
|
|
73
|
+
3. One step at a time — never start step N+1 before step N's commit
|
|
74
|
+
lands.
|
|
75
|
+
4. Once the controller (and queue step, if applicable) for a module is
|
|
76
|
+
committed, that module's Phase A is closed — say so plainly. Phase B
|
|
77
|
+
(`front-end-eng`, after `ux-planner`) can start once `reviewer` clears
|
|
78
|
+
the Phase Transition Check.
|
|
79
|
+
|
|
80
|
+
## Constraints
|
|
81
|
+
|
|
82
|
+
- Never import another module's repository, service, or schema directly
|
|
83
|
+
— cross-module references are FK-by-ID, resolved at the
|
|
84
|
+
contract/controller layer (parallel calls) or via a same-repository
|
|
85
|
+
Drizzle join against the other module's *schema*, never its adapter.
|
|
86
|
+
- Never write a queue step when the Queue add-on is off, or when the
|
|
87
|
+
operation doesn't actually need async — a felt need for one either way
|
|
88
|
+
is a Correction Protocol case or a `planner` add-on question, not a
|
|
89
|
+
unilateral addition.
|
|
90
|
+
- Never write frontend code (`apps/web`, `apps/mobile`,
|
|
91
|
+
`packages/hooks`) — that's `front-end-eng`'s Phase B, and it doesn't
|
|
92
|
+
start until yours closes.
|
|
93
|
+
- Never install new dependencies without flagging it first — the stack is
|
|
94
|
+
locked; a felt need for a new library usually signals the stack needs
|
|
95
|
+
revisiting, not a per-project exception.
|
|
96
|
+
- Never re-validate past the contract boundary — a service-level
|
|
97
|
+
invariant the Zod schema can't express is a thrown domain error, not a
|
|
98
|
+
second parse.
|
|
99
|
+
- If a downstream step reveals an upstream one (yours or another
|
|
100
|
+
module's) was wrong, stop and fix it at the source — the Correction
|
|
101
|
+
Protocol, not a workaround layered on top.
|
package/src/agents/bootstrap.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bootstrap
|
|
3
|
-
description: Use once per invocation, at the start of a new Hedgehog project, to land core (via hedgehog-bootstrap-core, one pass) then run exactly ONE add-on step of the hedgehog-bootstrap skill (0-3 steps depending on planning intake scope), handing off to a fresh instance of itself for the next add-on step. Not for per-module work — that's hedgehog-loop and its agents (planner,
|
|
3
|
+
description: Use once per invocation, at the start of a new Hedgehog project, to land core (via hedgehog-bootstrap-core, one pass) then run exactly ONE add-on step of the hedgehog-bootstrap skill (0-3 steps depending on planning intake scope), handing off to a fresh instance of itself for the next add-on step. Not for per-module work — that's hedgehog-loop and its agents (planner, backend-eng, front-end-eng, reviewer). Skip entirely if nx.json already exists.
|
|
4
4
|
model: sonnet
|
|
5
5
|
color: green
|
|
6
6
|
tools: Read, Glob, Grep, Edit, Write, Bash
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: front-end-eng
|
|
3
3
|
description: Use for the hook and screen steps once Phase A has closed for the module in scope. Specializes in the Hedgehog stack's frontend layer — Next.js, TanStack Query, ShadCN, Tailwind (+ Expo/React Native Reusables/NativeWind if mobile is in scope).
|
|
4
4
|
model: sonnet
|
|
5
5
|
color: blue
|
|
6
6
|
tools: Read, Glob, Grep, Edit, Write, Bash
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
You are the
|
|
9
|
+
You are the front-end-eng role in the Hedgehog discipline, building Phase B
|
|
10
10
|
(`apps/web`, `apps/mobile`) against an already-finished, typed API. The
|
|
11
|
-
backend isn't yours to change — Phase A
|
|
12
|
-
the contract (`packages/contracts`) is the fixed shape you
|
|
13
|
-
If the contract doesn't fit what the screen needs, that's a
|
|
14
|
-
Protocol case (patch the contract at its source, in Phase A,
|
|
15
|
-
`hedgehog-loop`), not something to work around in the UI.
|
|
11
|
+
backend isn't yours to change — `backend-eng` closed Phase A before you
|
|
12
|
+
started, and the contract (`packages/contracts`) is the fixed shape you
|
|
13
|
+
build against. If the contract doesn't fit what the screen needs, that's a
|
|
14
|
+
Correction Protocol case (patch the contract at its source, in Phase A,
|
|
15
|
+
per `hedgehog-loop`), not something to work around in the UI.
|
|
16
16
|
|
|
17
17
|
## Stack (locked)
|
|
18
18
|
|
|
@@ -26,6 +26,12 @@ Protocol case (patch the contract at its source, in Phase A, per
|
|
|
26
26
|
you talk to the API. Never call `fetch`/`axios` against `apps/api`
|
|
27
27
|
routes directly.
|
|
28
28
|
|
|
29
|
+
Use the `nx-run-tasks` skill to run build/lint/test/typecheck,
|
|
30
|
+
`nx-workspace` to inspect project/target config when a task fails or a
|
|
31
|
+
boundary is unclear, `nx-generate` if a step calls for scaffolding a new
|
|
32
|
+
library/app rather than hand-writing it, and `link-workspace-packages`
|
|
33
|
+
when a new package needs wiring into a consumer's dependencies.
|
|
34
|
+
|
|
29
35
|
## Core Responsibilities
|
|
30
36
|
|
|
31
37
|
- **Step 6 (hook)**: build the TanStack Query hook in `packages/hooks`,
|
package/src/agents/reviewer.md
CHANGED
|
@@ -7,12 +7,12 @@ tools: Read, Glob, Grep, Bash
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
You are the reviewer role in the Hedgehog discipline. The Loop
|
|
10
|
-
(`hedgehog-loop` skill) is a
|
|
11
|
-
|
|
12
|
-
judgment calls the mechanical gates (wired at
|
|
13
|
-
make: whether a module's boundaries and shape
|
|
14
|
-
just whether it compiles. You don't run on every
|
|
15
|
-
already covers that.
|
|
10
|
+
(`hedgehog-loop` skill) is a gate-driven procedure — delegate one step to
|
|
11
|
+
`backend-eng` or `front-end-eng`, run typecheck/lint/test, commit, repeat.
|
|
12
|
+
You exist for the judgment calls the mechanical gates (wired at
|
|
13
|
+
`hedgehog-bootstrap`) can't make: whether a module's boundaries and shape
|
|
14
|
+
are actually right, not just whether it compiles. You don't run on every
|
|
15
|
+
commit — the gate already covers that.
|
|
16
16
|
|
|
17
17
|
## When you run
|
|
18
18
|
|
package/src/agents/ux-planner.md
CHANGED
|
@@ -11,10 +11,10 @@ You are the ux-planner role in the Hedgehog discipline. Planning intake
|
|
|
11
11
|
feel" to Phase B rather than deciding it up front, alongside the domain
|
|
12
12
|
model. You are where that deferral resolves: the judgment call that
|
|
13
13
|
happens after a module's contract and hook exist, and before
|
|
14
|
-
`
|
|
14
|
+
`front-end-eng` writes a single component. `front-end-eng` implements — it
|
|
15
15
|
doesn't decide information hierarchy, interaction pattern, or which
|
|
16
16
|
usability tradeoffs apply. You decide those, once, per module, so
|
|
17
|
-
`
|
|
17
|
+
`front-end-eng` builds against a rationale instead of improvising one
|
|
18
18
|
mid-implementation.
|
|
19
19
|
|
|
20
20
|
## When you run
|
|
@@ -73,7 +73,7 @@ mockup, not a design system, not code:
|
|
|
73
73
|
it versus decided independently.
|
|
74
74
|
|
|
75
75
|
Keep it short — a few bullets per screen, not a document. This is a
|
|
76
|
-
rationale `
|
|
76
|
+
rationale `front-end-eng` reads once before starting, and `reviewer` can
|
|
77
77
|
check against later — not a spec either cross-checks line by line.
|
|
78
78
|
|
|
79
79
|
## Heuristics you draw on
|
|
@@ -99,10 +99,10 @@ reasoning tools, not a checklist to recite:
|
|
|
99
99
|
flat list of every schema column.
|
|
100
100
|
- **Visibility of system status** — every mutation (the hook layer's
|
|
101
101
|
operations) has a corresponding loading/success/error state named
|
|
102
|
-
here, not left for `
|
|
102
|
+
here, not left for `front-end-eng` to decide ad hoc.
|
|
103
103
|
|
|
104
104
|
Cite the specific heuristic behind each nontrivial recommendation so
|
|
105
|
-
`
|
|
105
|
+
`front-end-eng` and `reviewer` can trace the reasoning, not just the
|
|
106
106
|
conclusion.
|
|
107
107
|
|
|
108
108
|
## Workflow
|
|
@@ -124,11 +124,11 @@ conclusion.
|
|
|
124
124
|
patterns (Jakob's Law applies to this codebase's own prior screens
|
|
125
125
|
first, external conventions second).
|
|
126
126
|
7. Write `docs/design/<module>.md` per "What you produce," above.
|
|
127
|
-
8. Hand off to `
|
|
127
|
+
8. Hand off to `front-end-eng` for the screen step. The file isn't a step in
|
|
128
128
|
the Domain Module Pattern and isn't committed on its own — it lands in
|
|
129
129
|
the same commit as the screen step it informs
|
|
130
130
|
(`feat(<module>): screen-web` / `screen-mobile`), same as any other
|
|
131
|
-
file `
|
|
131
|
+
file `front-end-eng` touches while building that step.
|
|
132
132
|
|
|
133
133
|
## Constraints
|
|
134
134
|
|
|
@@ -137,7 +137,7 @@ conclusion.
|
|
|
137
137
|
file type. Read-only against `.hedgehog/BMAD/` too — archival record,
|
|
138
138
|
never edited.
|
|
139
139
|
- Never design visual style, color, typography, or branding — that's
|
|
140
|
-
`
|
|
140
|
+
`front-end-eng`'s call against the project's ShadCN/Tailwind setup, or a
|
|
141
141
|
design tool's output if one is wired into the project.
|
|
142
142
|
- Don't block the Loop. If the contract doesn't give enough to reason
|
|
143
143
|
about (e.g. no way to tell which fields matter most), ask one targeted
|
|
@@ -72,7 +72,9 @@ sequence.
|
|
|
72
72
|
## Domain Module — Backend Steps (Phase A, every module in scope)
|
|
73
73
|
|
|
74
74
|
A horizontal pass across the whole backend — every module goes through
|
|
75
|
-
these before any module gets a hook or screen.
|
|
75
|
+
these before any module gets a hook or screen. Delegate each module's
|
|
76
|
+
Phase A steps to the `backend-eng` agent — it builds one step, gates it,
|
|
77
|
+
commits it, and reports back.
|
|
76
78
|
|
|
77
79
|
| # | Step | Lives in | Commit |
|
|
78
80
|
|---|---|---|---|
|
|
@@ -95,9 +97,11 @@ callable (Postman/curl/contract tests) before frontend work starts.
|
|
|
95
97
|
| 7 | Screen | `apps/web` and/or `apps/mobile` | `feat(<module>): screen-web` / `feat(<module>): screen-mobile` |
|
|
96
98
|
|
|
97
99
|
Phase B starts once Phase A is done for the scope. The frontend is a pure
|
|
98
|
-
consumer of an already-finished API.
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
consumer of an already-finished API. Delegate each module's Phase B steps
|
|
101
|
+
to the `front-end-eng` agent, same reasoning as `backend-eng` for Phase A
|
|
102
|
+
— one step at a time, in its own context. Step 6a is where "how it should
|
|
103
|
+
feel" gets decided — once per module, after the hook exists and before
|
|
104
|
+
`front-end-eng` starts the screen — via `ux-planner`, starting from whatever
|
|
101
105
|
`planner` filed in `docs/design/<module>-notes.md` at planning intake. Its first run
|
|
102
106
|
for a module also signals to the user that Phase B has started, and is the
|
|
103
107
|
point a mockup, screenshot, or export (Google Stitch, Figma) can be handed
|
|
@@ -109,12 +113,14 @@ over. It writes `docs/design/<module>.md`, not its own step commit;
|
|
|
109
113
|
1. **Pick the next step** per the tables above, from `TODO.md`. One step
|
|
110
114
|
at a time, in order.
|
|
111
115
|
2. **Check the gate.** The prior step compiles and passes tests first.
|
|
112
|
-
3. **
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
3. **Delegate exactly one step** to `backend-eng` (Phase A) or
|
|
117
|
+
`front-end-eng` (Phase B) — one schema, one contract, one repository.
|
|
118
|
+
4. The agent **runs the gate on its own work**: typecheck, lint, test
|
|
119
|
+
(mirrors lefthook, wired at bootstrap).
|
|
120
|
+
5. The agent **commits** using the exact Conventional Commit format above.
|
|
121
|
+
6. **Check off the line in `TODO.md`** once the agent reports the commit
|
|
122
|
+
landed.
|
|
123
|
+
7. **Repeat**, one delegated step at a time.
|
|
118
124
|
|
|
119
125
|
Each commit batches exactly one step, built right for what's known now; a
|
|
120
126
|
wrong step is fixed forward later via the Correction Protocol.
|
|
@@ -194,7 +200,7 @@ boundary from planning intake (`planner`). If not, stop and ask.
|
|
|
194
200
|
- A module's frontend code (hook, screen) is built after its API is
|
|
195
201
|
committed.
|
|
196
202
|
- The screen step doesn't start blank — `ux-planner` runs once per module,
|
|
197
|
-
after the hook is committed, before `
|
|
203
|
+
after the hook is committed, before `front-end-eng` starts the screen.
|
|
198
204
|
- `packages/config` is the single source for shared config; a per-app
|
|
199
205
|
override request signals to fix the base config at the source.
|
|
200
206
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: link-workspace-packages
|
|
3
|
+
description: 'Link workspace packages in the Hedgehog pnpm monorepo. USE WHEN: (1) you just created or generated new packages and need to wire up their dependencies, (2) code imports from a sibling package and needs it added as a dependency, (3) you get resolution errors for workspace packages (@org/*) like "cannot find module", "failed to resolve import", "TS2307", or "cannot resolve". DO NOT patch around with tsconfig paths or manual package.json edits - use pnpm''s workspace commands to fix actual linking.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Link Workspace Packages
|
|
7
|
+
|
|
8
|
+
Add dependencies between packages in the workspace using pnpm's `workspace:` protocol — symlinks are only created when a dependency is explicitly declared this way.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Identify consumer package (the one importing)
|
|
13
|
+
2. Identify provider package(s) (being imported)
|
|
14
|
+
3. Add the dependency:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# From consumer directory
|
|
18
|
+
pnpm add @org/ui --workspace
|
|
19
|
+
|
|
20
|
+
# Or with --filter from anywhere
|
|
21
|
+
pnpm add @org/ui --filter @org/app --workspace
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Result in `package.json`:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{ "dependencies": { "@org/ui": "workspace:*" } }
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
4. Verify the symlink was created in the consumer's `node_modules/@org/<package>`
|
|
31
|
+
|
|
32
|
+
## Debugging "Cannot find module"
|
|
33
|
+
|
|
34
|
+
1. Check if the dependency is declared in the consumer's `package.json`
|
|
35
|
+
2. If not, add it using the command above
|
|
36
|
+
3. Run `pnpm install`
|
|
37
|
+
|
|
38
|
+
## Notes
|
|
39
|
+
|
|
40
|
+
- pnpm uses strict isolation (no hoisting) — a package must be an explicit dependency to be resolvable, even if it's installed elsewhere in the workspace. This prevents phantom deps.
|
|
41
|
+
- Root `package.json` should have `"private": true` to prevent accidental publish.
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nx-generate
|
|
3
|
+
description: Generate code using nx generators. INVOKE IMMEDIATELY when user mentions scaffolding, setup, structure, creating apps/libs, or setting up project structure. Trigger words - scaffold, setup, create a new app, create a new lib, project structure, generate, add a new project. ALWAYS use this BEFORE calling nx_docs or exploring - this skill handles discovery internally.
|
|
4
|
+
subagent: general-purpose
|
|
5
|
+
context: fork
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Run Nx Generator
|
|
9
|
+
|
|
10
|
+
Nx generators are powerful tools that scaffold projects, make automated code migrations or automate repetitive tasks in a monorepo. They ensure consistency across the codebase and reduce boilerplate work.
|
|
11
|
+
|
|
12
|
+
This skill applies when the user wants to:
|
|
13
|
+
|
|
14
|
+
- Create new projects like libraries or applications
|
|
15
|
+
- Scaffold features or boilerplate code
|
|
16
|
+
- Run workspace-specific or custom generators
|
|
17
|
+
- Do anything else that an nx generator exists for
|
|
18
|
+
|
|
19
|
+
## Key Principles
|
|
20
|
+
|
|
21
|
+
1. **Always use `--no-interactive`** - Prevents prompts that would hang execution
|
|
22
|
+
2. **Read the generator source code** - The schema alone is not enough; understand what the generator actually does
|
|
23
|
+
3. **Match existing repo patterns** - Study similar artifacts in the repo and follow their conventions
|
|
24
|
+
4. **Verify with lint/test/build/typecheck etc.** - Generated code must pass verification. The listed targets are just an example, use what's appropriate for this workspace.
|
|
25
|
+
|
|
26
|
+
## Steps
|
|
27
|
+
|
|
28
|
+
### 1. Discover Available Generators
|
|
29
|
+
|
|
30
|
+
Use the Nx CLI to discover available generators:
|
|
31
|
+
|
|
32
|
+
- List all generators for a plugin: `pnpm nx list @nx/react`
|
|
33
|
+
- View available plugins: `pnpm nx list`
|
|
34
|
+
|
|
35
|
+
This includes plugin generators (e.g., `@nx/react:library`) and local workspace generators.
|
|
36
|
+
|
|
37
|
+
### 2. Match Generator to User Request
|
|
38
|
+
|
|
39
|
+
Identify which generator(s) could fulfill the user's needs. Consider what artifact type they want, which framework is relevant, and any specific generator names mentioned.
|
|
40
|
+
|
|
41
|
+
**IMPORTANT**: When both a local workspace generator and an external plugin generator could satisfy the request, **always prefer the local workspace generator**. Local generators are customized for the specific repo's patterns.
|
|
42
|
+
|
|
43
|
+
If no suitable generator exists, you can stop using this skill. However, the burden of proof is high—carefully consider all available generators before deciding none apply.
|
|
44
|
+
|
|
45
|
+
### 3. Get Generator Options
|
|
46
|
+
|
|
47
|
+
Use the `--help` flag to understand available options:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pnpm nx g @nx/react:library --help
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Pay attention to required options, defaults that might need overriding, and options relevant to the user's request.
|
|
54
|
+
|
|
55
|
+
### Library Buildability
|
|
56
|
+
|
|
57
|
+
**Default to non-buildable libraries** unless there's a specific reason for buildable.
|
|
58
|
+
|
|
59
|
+
| Type | When to use | Generator flags |
|
|
60
|
+
| --------------------------- | ----------------------------------------------------------------- | ----------------------------------- |
|
|
61
|
+
| **Non-buildable** (default) | Internal monorepo libs consumed by apps | No `--bundler` flag |
|
|
62
|
+
| **Buildable** | Publishing to npm, cross-repo sharing, stable libs for cache hits | `--bundler=vite` or `--bundler=swc` |
|
|
63
|
+
|
|
64
|
+
Non-buildable libs:
|
|
65
|
+
|
|
66
|
+
- Export `.ts`/`.tsx` source directly
|
|
67
|
+
- Consumer's bundler compiles them
|
|
68
|
+
- Faster dev experience, less config
|
|
69
|
+
|
|
70
|
+
Buildable libs:
|
|
71
|
+
|
|
72
|
+
- Have their own build target
|
|
73
|
+
- Useful for stable libs that rarely change (cache hits)
|
|
74
|
+
- Required for npm publishing
|
|
75
|
+
|
|
76
|
+
**If unclear, ask the user:** "Should this library be buildable (own build step, better caching) or non-buildable (source consumed directly, simpler setup)?"
|
|
77
|
+
|
|
78
|
+
### 4. Read Generator Source Code
|
|
79
|
+
|
|
80
|
+
**This step is critical.** The schema alone does not tell you everything. Reading the source code helps you:
|
|
81
|
+
|
|
82
|
+
- Know exactly what files will be created/modified and where
|
|
83
|
+
- Understand side effects (updating configs, installing deps, etc.)
|
|
84
|
+
- Identify behaviors and options not obvious from the schema
|
|
85
|
+
- Understand how options interact with each other
|
|
86
|
+
|
|
87
|
+
To find generator source code:
|
|
88
|
+
|
|
89
|
+
- For plugin generators: Use `node -e "console.log(require.resolve('@nx/<plugin>/generators.json'));"` to find the generators.json, then locate the source from there
|
|
90
|
+
- If that fails, read directly from `node_modules/<plugin>/generators.json`
|
|
91
|
+
- For local generators: Typically in `tools/generators/` or a local plugin directory. Search the repo for the generator name.
|
|
92
|
+
|
|
93
|
+
After reading the source, reconsider: Is this the right generator? If not, go back to step 2.
|
|
94
|
+
|
|
95
|
+
> **⚠️ `--directory` flag behavior can be misleading.**
|
|
96
|
+
> It should specify the full path of the generated library or component, not the parent path that it will be generated in.
|
|
97
|
+
>
|
|
98
|
+
> ```bash
|
|
99
|
+
> # ✅ Correct - directory is the full path for the library
|
|
100
|
+
> nx g @nx/react:library --directory=libs/my-lib
|
|
101
|
+
> # generates libs/my-lib/package.json and more
|
|
102
|
+
>
|
|
103
|
+
> # ❌ Wrong - this will create files at libs and libs/src/...
|
|
104
|
+
> nx g @nx/react:library --name=my-lib --directory=libs
|
|
105
|
+
> # generates libs/package.json and more
|
|
106
|
+
> ```
|
|
107
|
+
|
|
108
|
+
### 5. Examine Existing Patterns
|
|
109
|
+
|
|
110
|
+
Before generating, examine the target area of the codebase:
|
|
111
|
+
|
|
112
|
+
- Look at similar existing artifacts (other libraries, applications, etc.)
|
|
113
|
+
- Identify naming conventions, file structures, and configuration patterns
|
|
114
|
+
- Note which test runners, build tools, and linters are used
|
|
115
|
+
- Configure the generator to match these patterns
|
|
116
|
+
|
|
117
|
+
### 6. Dry-Run to Verify File Placement
|
|
118
|
+
|
|
119
|
+
**Always run with `--dry-run` first** to verify files will be created in the correct location:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
pnpm nx g @nx/react:library --name=my-lib --dry-run --no-interactive
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Review the output carefully. If files would be created in the wrong location, adjust your options based on what you learned from the generator source code.
|
|
126
|
+
|
|
127
|
+
Note: Some generators don't support dry-run (e.g., if they install npm packages). If dry-run fails for this reason, proceed to running the generator for real.
|
|
128
|
+
|
|
129
|
+
### 7. Run the Generator
|
|
130
|
+
|
|
131
|
+
Execute the generator:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pnpm nx generate <generator-name> <options> --no-interactive
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
> **Tip:** New packages often need workspace dependencies wired up (e.g., importing shared types, being consumed by apps). The `link-workspace-packages` skill can help add these correctly.
|
|
138
|
+
|
|
139
|
+
### 8. Modify Generated Code (If Needed)
|
|
140
|
+
|
|
141
|
+
Generators provide a starting point. Modify the output as needed to:
|
|
142
|
+
|
|
143
|
+
- Add or modify functionality as requested
|
|
144
|
+
- Adjust imports, exports, or configurations
|
|
145
|
+
- Integrate with existing code patterns
|
|
146
|
+
|
|
147
|
+
**Important:** If you replace or delete generated test files (e.g., `*.spec.ts`), either write meaningful replacement tests or remove the `test` target from the project configuration. Empty test suites will cause `nx test` to fail.
|
|
148
|
+
|
|
149
|
+
### 9. Format and Verify
|
|
150
|
+
|
|
151
|
+
Format all generated/modified files:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
pnpm nx format --fix
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
This example is for built-in nx formatting with prettier. There might be other formatting tools for this workspace, use these when appropriate.
|
|
158
|
+
|
|
159
|
+
Then verify the generated code works. Keep in mind that the changes you make with a generator or subsequent modifications might impact various projects so it's usually not enough to only run targets for the artifact you just created.
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# these targets are just an example!
|
|
163
|
+
pnpm nx run-many -t build,lint,test,typecheck
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
These targets are common examples used across many workspaces. You should do research into other targets available for this workspace and its projects. CI configuration is usually a good guide for what the critical targets are that have to pass.
|
|
167
|
+
|
|
168
|
+
If verification fails with manageable issues (a few lint errors, minor type issues), fix them. If issues are extensive, attempt obvious fixes first, then escalate to the user with details about what was generated, what's failing, and what you've attempted.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nx-run-tasks
|
|
3
|
+
description: Helps with running tasks in an Nx workspace. USE WHEN the user wants to execute build, test, lint, serve, or run any other tasks defined in the workspace.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Run tasks with Nx via `pnpm nx` (Hedgehog workspaces are pnpm-only).
|
|
7
|
+
|
|
8
|
+
For more details on any command, run it with `--help` (e.g. `pnpm nx run-many --help`, `pnpm nx affected --help`).
|
|
9
|
+
|
|
10
|
+
## Understand which tasks can be run
|
|
11
|
+
|
|
12
|
+
You can check those via `pnpm nx show project <projectname> --json`, for example `pnpm nx show project myapp --json`. It contains a `targets` section which has information about targets that can be run. You can also just look at the `package.json` scripts or `project.json` targets, but you might miss out on inferred tasks by Nx plugins.
|
|
13
|
+
|
|
14
|
+
## Run a single task
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
pnpm nx run <project>:<task>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
where `project` is the project name defined in `package.json` or `project.json` (if present).
|
|
21
|
+
|
|
22
|
+
## Run multiple tasks
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
pnpm nx run-many -t build test lint typecheck
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
You can pass a `-p` flag to filter to specific projects, otherwise it runs on all projects. You can also use `--exclude` to exclude projects, and `--parallel` to control the number of parallel processes (default is 3).
|
|
29
|
+
|
|
30
|
+
Examples:
|
|
31
|
+
|
|
32
|
+
- `pnpm nx run-many -t test -p proj1 proj2` — test specific projects
|
|
33
|
+
- `pnpm nx run-many -t test --projects=*-app --exclude=excluded-app` — test projects matching a pattern
|
|
34
|
+
- `pnpm nx run-many -t test --projects=tag:api-*` — test projects by tag
|
|
35
|
+
|
|
36
|
+
## Run tasks for affected projects
|
|
37
|
+
|
|
38
|
+
Use `pnpm nx affected` to only run tasks on projects that have been changed and projects that depend on changed projects. This is especially useful in CI and for large workspaces.
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
pnpm nx affected -t build test lint
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
By default it compares against the base branch. You can customize this:
|
|
45
|
+
|
|
46
|
+
- `pnpm nx affected -t test --base=main --head=HEAD` — compare against a specific base and head
|
|
47
|
+
- `pnpm nx affected -t test --files=libs/mylib/src/index.ts` — specify changed files directly
|
|
48
|
+
|
|
49
|
+
## Useful flags
|
|
50
|
+
|
|
51
|
+
These flags work with `run`, `run-many`, and `affected`:
|
|
52
|
+
|
|
53
|
+
- `--skipNxCache` — rerun tasks even when results are cached
|
|
54
|
+
- `--verbose` — print additional information such as stack traces
|
|
55
|
+
- `--nxBail` — stop execution after the first failed task
|
|
56
|
+
- `--configuration=<name>` — use a specific configuration (e.g. `production`)
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nx-workspace
|
|
3
|
+
description: "Explore and understand Nx workspaces. USE WHEN answering questions about the workspace, projects, or tasks. ALSO USE WHEN an nx command fails or you need to check available targets/configuration before running a task. EXAMPLES: 'What projects are in this workspace?', 'How is project X configured?', 'What depends on library Y?', 'What targets can I run?', 'Cannot find configuration for task', 'debug nx task failure'."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Nx Workspace Exploration
|
|
7
|
+
|
|
8
|
+
This skill provides read-only exploration of Nx workspaces. Use it to understand workspace structure, project configuration, available targets, and dependencies.
|
|
9
|
+
|
|
10
|
+
Run all commands via `pnpm nx` (Hedgehog workspaces are pnpm-only).
|
|
11
|
+
|
|
12
|
+
## Listing Projects
|
|
13
|
+
|
|
14
|
+
Use `pnpm nx show projects` to list projects in the workspace.
|
|
15
|
+
|
|
16
|
+
The project filtering syntax (`-p`/`--projects`) works across many Nx commands including `nx run-many`, `nx release`, `nx show projects`, and more. Filters support explicit names, glob patterns, tag references (e.g. `tag:name`), directories, and negation (e.g. `!project-name`).
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# List all projects
|
|
20
|
+
pnpm nx show projects
|
|
21
|
+
|
|
22
|
+
# Filter by pattern (glob)
|
|
23
|
+
pnpm nx show projects --projects "apps/*"
|
|
24
|
+
pnpm nx show projects --projects "shared-*"
|
|
25
|
+
|
|
26
|
+
# Filter by tag
|
|
27
|
+
pnpm nx show projects --projects "tag:publishable"
|
|
28
|
+
pnpm nx show projects -p 'tag:publishable,!tag:internal'
|
|
29
|
+
|
|
30
|
+
# Filter by target (projects that have a specific target)
|
|
31
|
+
pnpm nx show projects --withTarget build
|
|
32
|
+
|
|
33
|
+
# Combine filters
|
|
34
|
+
pnpm nx show projects --type lib --withTarget test
|
|
35
|
+
pnpm nx show projects --affected --exclude="*-e2e"
|
|
36
|
+
pnpm nx show projects -p "tag:scope:client,packages/*"
|
|
37
|
+
|
|
38
|
+
# Negate patterns
|
|
39
|
+
pnpm nx show projects -p '!tag:private'
|
|
40
|
+
pnpm nx show projects -p '!*-e2e'
|
|
41
|
+
|
|
42
|
+
# Output as JSON
|
|
43
|
+
pnpm nx show projects --json
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Project Configuration
|
|
47
|
+
|
|
48
|
+
Use `pnpm nx show project <name> --json` to get the full resolved configuration for a project.
|
|
49
|
+
|
|
50
|
+
**Important**: Do NOT read `project.json` directly - it only contains partial configuration. The `nx show project --json` command returns the full resolved config including inferred targets from plugins.
|
|
51
|
+
|
|
52
|
+
You can read the full project schema at `node_modules/nx/schemas/project-schema.json` to understand nx project configuration options.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Get full project configuration
|
|
56
|
+
pnpm nx show project my-app --json
|
|
57
|
+
|
|
58
|
+
# Extract specific parts from the JSON
|
|
59
|
+
pnpm nx show project my-app --json | jq '.targets'
|
|
60
|
+
pnpm nx show project my-app --json | jq '.targets.build'
|
|
61
|
+
pnpm nx show project my-app --json | jq '.targets | keys'
|
|
62
|
+
|
|
63
|
+
# Check project metadata
|
|
64
|
+
pnpm nx show project my-app --json | jq '{name, root, sourceRoot, projectType, tags}'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Target Information
|
|
68
|
+
|
|
69
|
+
Targets define what tasks can be run on a project.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# List all targets for a project
|
|
73
|
+
pnpm nx show project my-app --json | jq '.targets | keys'
|
|
74
|
+
|
|
75
|
+
# Get full target configuration
|
|
76
|
+
pnpm nx show project my-app --json | jq '.targets.build'
|
|
77
|
+
|
|
78
|
+
# Check target executor/command
|
|
79
|
+
pnpm nx show project my-app --json | jq '.targets.build.executor'
|
|
80
|
+
pnpm nx show project my-app --json | jq '.targets.build.command'
|
|
81
|
+
|
|
82
|
+
# View target options
|
|
83
|
+
pnpm nx show project my-app --json | jq '.targets.build.options'
|
|
84
|
+
|
|
85
|
+
# Check target inputs/outputs (for caching)
|
|
86
|
+
pnpm nx show project my-app --json | jq '.targets.build.inputs'
|
|
87
|
+
pnpm nx show project my-app --json | jq '.targets.build.outputs'
|
|
88
|
+
|
|
89
|
+
# Find projects with a specific target
|
|
90
|
+
pnpm nx show projects --withTarget serve
|
|
91
|
+
pnpm nx show projects --withTarget e2e
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Workspace Configuration
|
|
95
|
+
|
|
96
|
+
Read `nx.json` directly for workspace-level configuration.
|
|
97
|
+
You can read the full project schema at `node_modules/nx/schemas/nx-schema.json` to understand nx project configuration options.
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Read the full nx.json
|
|
101
|
+
cat nx.json
|
|
102
|
+
|
|
103
|
+
# Or use jq for specific sections
|
|
104
|
+
cat nx.json | jq '.targetDefaults'
|
|
105
|
+
cat nx.json | jq '.namedInputs'
|
|
106
|
+
cat nx.json | jq '.plugins'
|
|
107
|
+
cat nx.json | jq '.generators'
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Key nx.json sections:
|
|
111
|
+
|
|
112
|
+
- `targetDefaults` - Default configuration applied to all targets of a given name
|
|
113
|
+
- `namedInputs` - Reusable input definitions for caching
|
|
114
|
+
- `plugins` - Nx plugins and their configuration
|
|
115
|
+
- ...and much more, read the schema or nx.json for details
|
|
116
|
+
|
|
117
|
+
## Affected Projects
|
|
118
|
+
|
|
119
|
+
If the user is asking about affected projects, read the [affected projects reference](references/AFFECTED.md) for detailed commands and examples.
|
|
120
|
+
|
|
121
|
+
## Common Exploration Patterns
|
|
122
|
+
|
|
123
|
+
### "What's in this workspace?"
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pnpm nx show projects
|
|
127
|
+
pnpm nx show projects --type app
|
|
128
|
+
pnpm nx show projects --type lib
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### "How do I build/test/lint project X?"
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pnpm nx show project X --json | jq '.targets | keys'
|
|
135
|
+
pnpm nx show project X --json | jq '.targets.build'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### "What depends on library Y?"
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Use the project graph to find dependents
|
|
142
|
+
pnpm nx graph --print | jq '.graph.dependencies | to_entries[] | select(.value[].target == "Y") | .key'
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Programmatic Answers
|
|
146
|
+
|
|
147
|
+
When processing nx CLI results, use command-line tools to compute the answer programmatically rather than counting or parsing output manually. Always use `--json` flags to get structured output that can be processed with `jq`, `grep`, or other tools you have installed locally.
|
|
148
|
+
|
|
149
|
+
### Listing Projects
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
pnpm nx show projects --json
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Example output:
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
["my-app", "my-app-e2e", "shared-ui", "shared-utils", "api"]
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Common operations:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Count projects
|
|
165
|
+
pnpm nx show projects --json | jq 'length'
|
|
166
|
+
|
|
167
|
+
# Filter by pattern
|
|
168
|
+
pnpm nx show projects --json | jq '.[] | select(startswith("shared-"))'
|
|
169
|
+
|
|
170
|
+
# Get affected projects as array
|
|
171
|
+
pnpm nx show projects --affected --json | jq '.'
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Project Details
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
pnpm nx show project my-app --json
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Example output:
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"root": "apps/my-app",
|
|
185
|
+
"name": "my-app",
|
|
186
|
+
"sourceRoot": "apps/my-app/src",
|
|
187
|
+
"projectType": "application",
|
|
188
|
+
"tags": ["type:app", "scope:client"],
|
|
189
|
+
"targets": {
|
|
190
|
+
"build": {
|
|
191
|
+
"executor": "@nx/vite:build",
|
|
192
|
+
"options": { "outputPath": "dist/apps/my-app" }
|
|
193
|
+
},
|
|
194
|
+
"serve": {
|
|
195
|
+
"executor": "@nx/vite:dev-server",
|
|
196
|
+
"options": { "buildTarget": "my-app:build" }
|
|
197
|
+
},
|
|
198
|
+
"test": {
|
|
199
|
+
"executor": "@nx/vite:test",
|
|
200
|
+
"options": {}
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
"implicitDependencies": []
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Common operations:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Get target names
|
|
211
|
+
pnpm nx show project my-app --json | jq '.targets | keys'
|
|
212
|
+
|
|
213
|
+
# Get specific target config
|
|
214
|
+
pnpm nx show project my-app --json | jq '.targets.build'
|
|
215
|
+
|
|
216
|
+
# Get tags
|
|
217
|
+
pnpm nx show project my-app --json | jq '.tags'
|
|
218
|
+
|
|
219
|
+
# Get project root
|
|
220
|
+
pnpm nx show project my-app --json | jq -r '.root'
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Project Graph
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
pnpm nx graph --print
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Example output:
|
|
230
|
+
|
|
231
|
+
```json
|
|
232
|
+
{
|
|
233
|
+
"graph": {
|
|
234
|
+
"nodes": {
|
|
235
|
+
"my-app": {
|
|
236
|
+
"name": "my-app",
|
|
237
|
+
"type": "app",
|
|
238
|
+
"data": { "root": "apps/my-app", "tags": ["type:app"] }
|
|
239
|
+
},
|
|
240
|
+
"shared-ui": {
|
|
241
|
+
"name": "shared-ui",
|
|
242
|
+
"type": "lib",
|
|
243
|
+
"data": { "root": "libs/shared-ui", "tags": ["type:ui"] }
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
"dependencies": {
|
|
247
|
+
"my-app": [
|
|
248
|
+
{ "source": "my-app", "target": "shared-ui", "type": "static" }
|
|
249
|
+
],
|
|
250
|
+
"shared-ui": []
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Common operations:
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
# Get all project names from graph
|
|
260
|
+
pnpm nx graph --print | jq '.graph.nodes | keys'
|
|
261
|
+
|
|
262
|
+
# Find dependencies of a project
|
|
263
|
+
pnpm nx graph --print | jq '.graph.dependencies["my-app"]'
|
|
264
|
+
|
|
265
|
+
# Find projects that depend on a library
|
|
266
|
+
pnpm nx graph --print | jq '.graph.dependencies | to_entries[] | select(.value[].target == "shared-ui") | .key'
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Troubleshooting
|
|
270
|
+
|
|
271
|
+
### "Cannot find configuration for task X:target"
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# Check what targets exist on the project
|
|
275
|
+
pnpm nx show project X --json | jq '.targets | keys'
|
|
276
|
+
|
|
277
|
+
# Check if any projects have that target
|
|
278
|
+
pnpm nx show projects --withTarget target
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### "The workspace is out of sync"
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
pnpm nx sync
|
|
285
|
+
pnpm nx reset # if sync doesn't fix stale cache
|
|
286
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
## Affected Projects
|
|
2
|
+
|
|
3
|
+
Find projects affected by changes in the current branch.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# Affected since base branch (auto-detected)
|
|
7
|
+
pnpm nx show projects --affected
|
|
8
|
+
|
|
9
|
+
# Affected with explicit base
|
|
10
|
+
pnpm nx show projects --affected --base=main
|
|
11
|
+
pnpm nx show projects --affected --base=origin/main
|
|
12
|
+
|
|
13
|
+
# Affected between two commits
|
|
14
|
+
pnpm nx show projects --affected --base=abc123 --head=def456
|
|
15
|
+
|
|
16
|
+
# Affected apps only
|
|
17
|
+
pnpm nx show projects --affected --type app
|
|
18
|
+
|
|
19
|
+
# Affected excluding e2e projects
|
|
20
|
+
pnpm nx show projects --affected --exclude="*-e2e"
|
|
21
|
+
|
|
22
|
+
# Affected by uncommitted changes
|
|
23
|
+
pnpm nx show projects --affected --uncommitted
|
|
24
|
+
|
|
25
|
+
# Affected by untracked files
|
|
26
|
+
pnpm nx show projects --affected --untracked
|
|
27
|
+
```
|
package/src/templates/CLAUDE.md
CHANGED
|
@@ -95,9 +95,13 @@ steps from memory:
|
|
|
95
95
|
whichever add-on steps planning intake turned on. Triggered
|
|
96
96
|
automatically by `planner` after its first run; skip if `nx.json`
|
|
97
97
|
already exists.
|
|
98
|
+
- **`backend-eng`** — builds each module's Phase A steps (schema →
|
|
99
|
+
contract → repository → service → controller → queue?), one step at a
|
|
100
|
+
time, gated and committed in its own context.
|
|
98
101
|
- **`ux-planner`** — once per module in Phase B, after the hook exists and
|
|
99
102
|
before the screen: writes `docs/design/<module>.md`.
|
|
100
|
-
- **`
|
|
103
|
+
- **`front-end-eng`** — builds each module's Phase B steps (hook, screen)
|
|
104
|
+
from the ux-planner rationale, one step at a time, in its own context.
|
|
101
105
|
- **`reviewer`** — phase-transition and Correction Protocol checks the
|
|
102
106
|
mechanical gate can't make (port discipline, FK-by-ID discipline,
|
|
103
107
|
contract shape).
|
|
@@ -221,9 +225,10 @@ context small:
|
|
|
221
225
|
is available if the product narrative itself needs re-reading, but
|
|
222
226
|
day-to-day recovery doesn't need it.
|
|
223
227
|
- **Delegate heavy work to agents.** The project scaffold (`bootstrap`),
|
|
224
|
-
planning intake (`planner`),
|
|
225
|
-
reviews (`reviewer`) each run in
|
|
226
|
-
work doesn't pile up in the main
|
|
228
|
+
planning intake (`planner`), every Phase A step (`backend-eng`), every
|
|
229
|
+
Phase B step (`front-end-eng`), and reviews (`reviewer`) each run in
|
|
230
|
+
their own isolated context — so that work doesn't pile up in the main
|
|
231
|
+
thread.
|
|
227
232
|
- **Don't paste large context back in.** If you find yourself
|
|
228
233
|
re-explaining the architecture, stop — it's fixed and stated in this
|
|
229
234
|
file, not something to reconstruct. If you need a project specific, read
|