Skip to content

Commit 16d43de

Browse files
committed
chore: update from obsidian
1 parent 3445490 commit 16d43de

25 files changed

Lines changed: 3265 additions & 2 deletions

File tree

.github/agents/ci-monitor-subagent.agent.md

Lines changed: 616 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
name: link-workspace-packages
3+
description: 'Link workspace packages in monorepos (npm, yarn, pnpm, bun). USE WHEN: (1) you just created or generated new packages and need to wire up their dependencies, (2) user imports from a sibling package and needs to add it 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 the package manager''s workspace commands to fix actual linking.'
4+
---
5+
6+
# Link Workspace Packages
7+
8+
Add dependencies between packages in a monorepo. All package managers support workspaces but with different syntax.
9+
10+
## Detect Package Manager
11+
12+
Check whether there's a `packageManager` field in the root-level `package.json`.
13+
14+
Alternatively check lockfile in repo root:
15+
16+
- `pnpm-lock.yaml` → pnpm
17+
- `yarn.lock` → yarn
18+
- `bun.lock` / `bun.lockb` → bun
19+
- `package-lock.json` → npm
20+
21+
## Workflow
22+
23+
1. Identify consumer package (the one importing)
24+
2. Identify provider package(s) (being imported)
25+
3. Add dependency using package manager's workspace syntax
26+
4. Verify symlinks created in consumer's `node_modules/`
27+
28+
---
29+
30+
## pnpm
31+
32+
Uses `workspace:` protocol - symlinks only created when explicitly declared.
33+
34+
```bash
35+
# From consumer directory
36+
pnpm add @org/ui --workspace
37+
38+
# Or with --filter from anywhere
39+
pnpm add @org/ui --filter @org/app --workspace
40+
```
41+
42+
Result in `package.json`:
43+
44+
```json
45+
{ "dependencies": { "@org/ui": "workspace:*" } }
46+
```
47+
48+
---
49+
50+
## yarn (v2+/berry)
51+
52+
Also uses `workspace:` protocol.
53+
54+
```bash
55+
yarn workspace @org/app add @org/ui
56+
```
57+
58+
Result in `package.json`:
59+
60+
```json
61+
{ "dependencies": { "@org/ui": "workspace:^" } }
62+
```
63+
64+
---
65+
66+
## npm
67+
68+
No `workspace:` protocol. npm auto-symlinks workspace packages.
69+
70+
```bash
71+
npm install @org/ui --workspace @org/app
72+
```
73+
74+
Result in `package.json`:
75+
76+
```json
77+
{ "dependencies": { "@org/ui": "*" } }
78+
```
79+
80+
npm resolves to local workspace automatically during install.
81+
82+
---
83+
84+
## bun
85+
86+
Supports `workspace:` protocol (pnpm-compatible).
87+
88+
```bash
89+
cd packages/app && bun add @org/ui
90+
```
91+
92+
Result in `package.json`:
93+
94+
```json
95+
{ "dependencies": { "@org/ui": "workspace:*" } }
96+
```
97+
98+
---
99+
100+
## Examples
101+
102+
**Example 1: pnpm - link ui lib to app**
103+
104+
```bash
105+
pnpm add @org/ui --filter @org/app --workspace
106+
```
107+
108+
**Example 2: npm - link multiple packages**
109+
110+
```bash
111+
npm install @org/data-access @org/ui --workspace @org/dashboard
112+
```
113+
114+
**Example 3: Debug "Cannot find module"**
115+
116+
1. Check if dependency is declared in consumer's `package.json`
117+
2. If not, add it using appropriate command above
118+
3. Run install (`pnpm install`, `npm install`, etc.)
119+
120+
## Notes
121+
122+
- Symlinks appear in `<consumer>/node_modules/@org/<package>`
123+
- **Hoisting differs by manager:**
124+
- npm/bun: hoist shared deps to root `node_modules`
125+
- pnpm: no hoisting (strict isolation, prevents phantom deps)
126+
- yarn berry: uses Plug'n'Play by default (no `node_modules`)
127+
- Root `package.json` should have `"private": true` to prevent accidental publish

.github/skills/monitor-ci/SKILL.md

Lines changed: 671 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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 ... app, create a ... lib, project structure, generate, add a new project. ALWAYS use this BEFORE calling nx_docs or exploring - this skill handles discovery internally.
4+
---
5+
6+
# Run Nx Generator
7+
8+
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.
9+
10+
This skill applies when the user wants to:
11+
12+
- Create new projects like libraries or applications
13+
- Scaffold features or boilerplate code
14+
- Run workspace-specific or custom generators
15+
- Do anything else that an nx generator exists for
16+
17+
## Key Principles
18+
19+
1. **Always use `--no-interactive`** - Prevents prompts that would hang execution
20+
2. **Read the generator source code** - The schema alone is not enough; understand what the generator actually does
21+
3. **Match existing repo patterns** - Study similar artifacts in the repo and follow their conventions
22+
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.
23+
24+
## Steps
25+
26+
### 1. Discover Available Generators
27+
28+
Use the Nx CLI to discover available generators:
29+
30+
- List all generators for a plugin: `npx nx list @nx/react`
31+
- View available plugins: `npx nx list`
32+
33+
This includes plugin generators (e.g., `@nx/react:library`) and local workspace generators.
34+
35+
### 2. Match Generator to User Request
36+
37+
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.
38+
39+
**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.
40+
41+
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.
42+
43+
### 3. Get Generator Options
44+
45+
Use the `--help` flag to understand available options:
46+
47+
```bash
48+
npx nx g @nx/react:library --help
49+
```
50+
51+
Pay attention to required options, defaults that might need overriding, and options relevant to the user's request.
52+
53+
### Library Buildability
54+
55+
**Default to non-buildable libraries** unless there's a specific reason for buildable.
56+
57+
| Type | When to use | Generator flags |
58+
| --------------------------- | ----------------------------------------------------------------- | ----------------------------------- |
59+
| **Non-buildable** (default) | Internal monorepo libs consumed by apps | No `--bundler` flag |
60+
| **Buildable** | Publishing to npm, cross-repo sharing, stable libs for cache hits | `--bundler=vite` or `--bundler=swc` |
61+
62+
Non-buildable libs:
63+
64+
- Export `.ts`/`.tsx` source directly
65+
- Consumer's bundler compiles them
66+
- Faster dev experience, less config
67+
68+
Buildable libs:
69+
70+
- Have their own build target
71+
- Useful for stable libs that rarely change (cache hits)
72+
- Required for npm publishing
73+
74+
**If unclear, ask the user:** "Should this library be buildable (own build step, better caching) or non-buildable (source consumed directly, simpler setup)?"
75+
76+
### 4. Read Generator Source Code
77+
78+
**This step is critical.** The schema alone does not tell you everything. Reading the source code helps you:
79+
80+
- Know exactly what files will be created/modified and where
81+
- Understand side effects (updating configs, installing deps, etc.)
82+
- Identify behaviors and options not obvious from the schema
83+
- Understand how options interact with each other
84+
85+
To find generator source code:
86+
87+
- 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
88+
- If that fails, read directly from `node_modules/<plugin>/generators.json`
89+
- For local generators: Typically in `tools/generators/` or a local plugin directory. Search the repo for the generator name.
90+
91+
After reading the source, reconsider: Is this the right generator? If not, go back to step 2.
92+
93+
> **⚠️ `--directory` flag behavior can be misleading.**
94+
> It should specify the full path of the generated library or component, not the parent path that it will be generated in.
95+
>
96+
> ```bash
97+
> # ✅ Correct - directory is the full path for the library
98+
> nx g @nx/react:library --directory=libs/my-lib
99+
> # generates libs/my-lib/package.json and more
100+
>
101+
> # ❌ Wrong - this will create files at libs and libs/src/...
102+
> nx g @nx/react:library --name=my-lib --directory=libs
103+
> # generates libs/package.json and more
104+
> ```
105+
106+
### 5. Examine Existing Patterns
107+
108+
Before generating, examine the target area of the codebase:
109+
110+
- Look at similar existing artifacts (other libraries, applications, etc.)
111+
- Identify naming conventions, file structures, and configuration patterns
112+
- Note which test runners, build tools, and linters are used
113+
- Configure the generator to match these patterns
114+
115+
### 6. Dry-Run to Verify File Placement
116+
117+
**Always run with `--dry-run` first** to verify files will be created in the correct location:
118+
119+
```bash
120+
npx nx g @nx/react:library --name=my-lib --dry-run --no-interactive
121+
```
122+
123+
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.
124+
125+
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.
126+
127+
### 7. Run the Generator
128+
129+
Execute the generator:
130+
131+
```bash
132+
nx generate <generator-name> <options> --no-interactive
133+
```
134+
135+
> **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.
136+
137+
### 8. Modify Generated Code (If Needed)
138+
139+
Generators provide a starting point. Modify the output as needed to:
140+
141+
- Add or modify functionality as requested
142+
- Adjust imports, exports, or configurations
143+
- Integrate with existing code patterns
144+
145+
**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.
146+
147+
### 9. Format and Verify
148+
149+
Format all generated/modified files:
150+
151+
```bash
152+
nx format --fix
153+
```
154+
155+
This example is for built-in nx formatting with prettier. There might be other formatting tools for this workspace, use these when appropriate.
156+
157+
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.
158+
159+
```bash
160+
# these targets are just an example!
161+
nx run-many -t build,lint,test,typecheck
162+
```
163+
164+
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.
165+
166+
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 commit comments

Comments
 (0)