@skyf0xx/hedgehog 0.1.18 → 0.1.20
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 +7 -1
- package/package.json +1 -1
- package/src/agents/backend-eng.md +6 -0
- package/src/agents/front-end-eng.md +6 -0
- package/src/golden-core/apps/api/package.json +2 -0
- package/src/golden-core/pnpm-lock.yaml +42 -0
- 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/README.md
CHANGED
|
@@ -159,7 +159,7 @@ Hedgehog runs BMAD for planning, then enforces the build that follows with tooli
|
|
|
159
159
|
|
|
160
160
|
| | Superpowers | BMAD | Hedgehog + BMAD |
|
|
161
161
|
| --- | --- | --- | --- |
|
|
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 →
|
|
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 |
|
|
163
163
|
| **Order comes from** | Skill instructions the agent is told to follow | Sequenced documents (brief → PRD → architecture → stories) | Tooling (Nx, lefthook, phase gate) |
|
|
164
164
|
| **Enforcement mechanism** | None. Prompted convention | None. One optional checklist between phases | Execution mechanically enforced |
|
|
165
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) |
|
|
@@ -173,6 +173,12 @@ Hedgehog runs BMAD for planning, then enforces the build that follows with tooli
|
|
|
173
173
|
Planning intake runs on [BMAD-METHOD](https://github.com/bmad-code-org/BMAD-METHOD)
|
|
174
174
|
(`bmad-code-org/BMAD-METHOD`) MIT-licensed.
|
|
175
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
|
+
|
|
176
182
|
## Support Hedgehog
|
|
177
183
|
|
|
178
184
|
If Hedgehog helps you build better AI software, consider giving it a ⭐ on GitHub.
|
package/package.json
CHANGED
|
@@ -29,6 +29,12 @@ handed to you, one step at a time, gated before the next starts.
|
|
|
29
29
|
fan-out).
|
|
30
30
|
- **PostgreSQL** via Docker Compose — never a natively-installed Postgres.
|
|
31
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
|
+
|
|
32
38
|
## Core Responsibilities
|
|
33
39
|
|
|
34
40
|
- **Step 1 (schema)**: define the table in `packages/db` (Drizzle). One
|
|
@@ -26,6 +26,12 @@ per `hedgehog-loop`), not something to work around in the UI.
|
|
|
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`,
|
|
@@ -212,6 +212,12 @@ importers:
|
|
|
212
212
|
'@nestjs/platform-express':
|
|
213
213
|
specifier: ^11.0.0
|
|
214
214
|
version: 11.1.28(@nestjs/common@11.1.28(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@11.1.28)
|
|
215
|
+
'@ts-rest/core':
|
|
216
|
+
specifier: 3.53.0-rc.1
|
|
217
|
+
version: 3.53.0-rc.1(@types/node@22.20.1)
|
|
218
|
+
'@ts-rest/nest':
|
|
219
|
+
specifier: 3.53.0-rc.1
|
|
220
|
+
version: 3.53.0-rc.1(@nestjs/common@11.1.28(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@11.1.28(@nestjs/common@11.1.28(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@11.1.28)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@ts-rest/core@3.53.0-rc.1(@types/node@22.20.1))(rxjs@7.8.1)
|
|
215
221
|
config:
|
|
216
222
|
specifier: workspace:*
|
|
217
223
|
version: link:../../packages/config
|
|
@@ -284,6 +290,9 @@ importers:
|
|
|
284
290
|
|
|
285
291
|
packages/config:
|
|
286
292
|
dependencies:
|
|
293
|
+
'@ts-rest/core':
|
|
294
|
+
specifier: 3.53.0-rc.1
|
|
295
|
+
version: 3.53.0-rc.1(@types/node@22.20.1)
|
|
287
296
|
zod:
|
|
288
297
|
specifier: ^4.0.0
|
|
289
298
|
version: 4.4.3
|
|
@@ -4515,6 +4524,28 @@ packages:
|
|
|
4515
4524
|
integrity: sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==,
|
|
4516
4525
|
}
|
|
4517
4526
|
|
|
4527
|
+
'@ts-rest/core@3.53.0-rc.1':
|
|
4528
|
+
resolution:
|
|
4529
|
+
{
|
|
4530
|
+
integrity: sha512-hDMXqKHSys6w+kXFW1Q6EvN8QgRvtXKXJ2TpYByKI4TquaPjiTOv99aLD26X4LNRzdna8Ci1PVyzr0jYZv0oNQ==,
|
|
4531
|
+
}
|
|
4532
|
+
peerDependencies:
|
|
4533
|
+
'@types/node': ^18.18.7 || >=20.8.4
|
|
4534
|
+
peerDependenciesMeta:
|
|
4535
|
+
'@types/node':
|
|
4536
|
+
optional: true
|
|
4537
|
+
|
|
4538
|
+
'@ts-rest/nest@3.53.0-rc.1':
|
|
4539
|
+
resolution:
|
|
4540
|
+
{
|
|
4541
|
+
integrity: sha512-tiuxTwXElFrAGFiUpqn78HmGgVY848D5s+uz/wCQwzRgPsfEneeZwOnEtxvXyrAp6tS5VtbVIxrI/kD+yR2zjw==,
|
|
4542
|
+
}
|
|
4543
|
+
peerDependencies:
|
|
4544
|
+
'@nestjs/common': ^9.0.0 || ^10.0.0 || ^11.0.0
|
|
4545
|
+
'@nestjs/core': ^9.0.0 || ^10.0.0 || ^11.0.0
|
|
4546
|
+
'@ts-rest/core': 3.53.0-rc.1
|
|
4547
|
+
rxjs: ^7.1.0
|
|
4548
|
+
|
|
4518
4549
|
'@tybys/wasm-util@0.10.3':
|
|
4519
4550
|
resolution:
|
|
4520
4551
|
{
|
|
@@ -16814,6 +16845,17 @@ snapshots:
|
|
|
16814
16845
|
|
|
16815
16846
|
'@tokenizer/token@0.3.0': {}
|
|
16816
16847
|
|
|
16848
|
+
'@ts-rest/core@3.53.0-rc.1(@types/node@22.20.1)':
|
|
16849
|
+
optionalDependencies:
|
|
16850
|
+
'@types/node': 22.20.1
|
|
16851
|
+
|
|
16852
|
+
'@ts-rest/nest@3.53.0-rc.1(@nestjs/common@11.1.28(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@11.1.28(@nestjs/common@11.1.28(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@11.1.28)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@ts-rest/core@3.53.0-rc.1(@types/node@22.20.1))(rxjs@7.8.1)':
|
|
16853
|
+
dependencies:
|
|
16854
|
+
'@nestjs/common': 11.1.28(reflect-metadata@0.2.2)(rxjs@7.8.1)
|
|
16855
|
+
'@nestjs/core': 11.1.28(@nestjs/common@11.1.28(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@11.1.28)(reflect-metadata@0.2.2)(rxjs@7.8.1)
|
|
16856
|
+
'@ts-rest/core': 3.53.0-rc.1(@types/node@22.20.1)
|
|
16857
|
+
rxjs: 7.8.1
|
|
16858
|
+
|
|
16817
16859
|
'@tybys/wasm-util@0.10.3':
|
|
16818
16860
|
dependencies:
|
|
16819
16861
|
tslib: 2.8.1
|
|
@@ -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
|
+
```
|