@uniswap/ai-toolkit-nx-claude 0.5.7-next.9 → 0.5.8
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 +15 -17
- package/dist/cli-generator.cjs +26 -37
- package/dist/content/agents/agnostic/claude-docs-initializer.md +458 -0
- package/dist/content/agents/agnostic/claude-docs-manager.md +412 -0
- package/dist/content/agents/agnostic/plan-reviewer.md +35 -21
- package/dist/content/agents/agnostic/planner.md +62 -73
- package/dist/content/agents/agnostic/pr-reviewer.md +142 -0
- package/dist/content/commands/agnostic/address-pr-issues.md +205 -0
- package/dist/content/commands/agnostic/claude-docs.md +393 -0
- package/dist/content/commands/agnostic/execute-plan.md +88 -288
- package/dist/content/commands/agnostic/explore.md +1 -1
- package/dist/content/commands/agnostic/plan.md +65 -201
- package/dist/content/commands/agnostic/review-plan.md +11 -12
- package/dist/generators/add-agent/generator.cjs +46 -2
- package/dist/generators/add-command/generator.cjs +46 -2
- package/dist/generators/addons/generator.cjs +80 -233
- package/dist/generators/addons/schema.json +0 -5
- package/dist/generators/hooks/generator.cjs +103 -2
- package/dist/generators/init/CLAUDE.md +277 -48
- package/dist/generators/init/generator.cjs +2077 -494
- package/dist/generators/init/schema.json +51 -21
- package/dist/index.cjs +1953 -0
- package/dist/packages/ai-toolkit-nx-claude/src/cli-generator.d.ts +0 -1
- package/dist/packages/ai-toolkit-nx-claude/src/cli-generator.d.ts.map +1 -1
- package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/addon-registry.d.ts +0 -4
- package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/addon-registry.d.ts.map +1 -1
- package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/generator.d.ts.map +1 -1
- package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/install-orchestrator.d.ts.map +1 -1
- package/dist/packages/ai-toolkit-nx-claude/src/generators/init/generator.d.ts.map +1 -1
- package/dist/packages/ai-toolkit-nx-claude/src/index.d.ts +3 -1
- package/dist/packages/ai-toolkit-nx-claude/src/index.d.ts.map +1 -1
- package/dist/packages/ai-toolkit-nx-claude/src/utils/auto-update-utils.d.ts +30 -0
- package/dist/packages/ai-toolkit-nx-claude/src/utils/auto-update-utils.d.ts.map +1 -0
- package/dist/packages/ai-toolkit-nx-claude/src/utils/prompt-utils.d.ts.map +1 -1
- package/generators.json +0 -5
- package/package.json +12 -3
- package/dist/generators/init/setup-github-packages.sh +0 -132
- package/dist/generators/setup-registry-proxy/README.md +0 -111
- package/dist/generators/setup-registry-proxy/files/uniswap-ai-toolkit.__shell__rc.template +0 -178
- package/dist/generators/setup-registry-proxy/generator.cjs +0 -227
- package/dist/generators/setup-registry-proxy/schema.json +0 -43
- package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/github-auth.d.ts +0 -36
- package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/github-auth.d.ts.map +0 -1
- package/dist/packages/ai-toolkit-nx-claude/src/generators/setup-registry-proxy/generator.d.ts +0 -5
- package/dist/packages/ai-toolkit-nx-claude/src/generators/setup-registry-proxy/generator.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -4,57 +4,55 @@ This package provides Nx generators for setting up and managing Claude Code conf
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
This package is published to
|
|
8
|
-
|
|
9
|
-
````bash
|
|
7
|
+
This package is published to a private npmjs package registry and requires authentication to access. See the [root README.md file](../../README.md) for instructions on how to install it via NPM, or run it locally
|
|
10
8
|
|
|
11
9
|
## Usage
|
|
12
10
|
|
|
13
11
|
### Run Default Generator
|
|
14
12
|
|
|
15
13
|
```bash
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
bun nx run @uniswap/ai-toolkit-nx-claude:nx-claude:exec
|
|
15
|
+
```
|
|
18
16
|
|
|
19
17
|
### Run Specific Generators
|
|
20
18
|
|
|
21
|
-
Each generator can be run directly
|
|
19
|
+
Each generator can be run directly desired generator's subcommand:
|
|
22
20
|
|
|
23
21
|
```bash
|
|
24
22
|
# One-shot installer for Claude Code configs
|
|
25
|
-
|
|
23
|
+
bun nx run @uniswap/ai-toolkit-nx-claude:nx-claude:exec init
|
|
26
24
|
|
|
27
25
|
# Install notification hooks
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# Setup shell proxy for GitHub registry routing
|
|
31
|
-
npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest setup-registry-proxy
|
|
26
|
+
bun nx run @uniswap/ai-toolkit-nx-claude:nx-claude:exec hooks
|
|
32
27
|
|
|
33
28
|
# Install and configure Claude Code addons
|
|
34
|
-
|
|
29
|
+
bun nx run @uniswap/ai-toolkit-nx-claude:nx-claude:exec addons
|
|
35
30
|
|
|
36
31
|
# Add a new command to packages
|
|
37
|
-
|
|
32
|
+
bun nx run @uniswap/ai-toolkit-nx-claude:nx-claude:exec add-command
|
|
38
33
|
|
|
39
34
|
# Add a new agent to packages
|
|
40
|
-
|
|
35
|
+
bun nx run @uniswap/ai-toolkit-nx-claude:nx-claude:exec add-agent
|
|
41
36
|
```
|
|
42
37
|
|
|
43
38
|
### List Available Generators
|
|
44
39
|
|
|
45
40
|
```bash
|
|
46
|
-
|
|
41
|
+
bun nx run @uniswap/ai-toolkit-nx-claude:nx-claude:exec --list
|
|
47
42
|
```
|
|
48
43
|
|
|
49
44
|
## Available Generators
|
|
50
45
|
|
|
51
46
|
- **init** - One-shot installer for Claude Code configs
|
|
52
47
|
- **hooks** - Install Claude Code notification hooks
|
|
53
|
-
- **setup-registry-proxy** - Setup shell proxy for routing @uniswap/ai-toolkit\* packages to GitHub registry
|
|
54
48
|
- **addons** - Install and configure Claude Code addons including MCP servers
|
|
55
49
|
- **add-command** - Add a new Claude Code command to existing or new packages
|
|
56
50
|
- **add-agent** - Add a new Claude Code agent to existing or new packages
|
|
57
51
|
|
|
58
52
|
## Building
|
|
59
53
|
|
|
60
|
-
Run `nx build ai-toolkit-nx-claude` to build the library.
|
|
54
|
+
Run `bun nx build ai-toolkit-nx-claude` to build the library.
|
|
55
|
+
|
|
56
|
+
## Testing
|
|
57
|
+
|
|
58
|
+
Run `bunx nx test ai-toolkit-nx-claude` to test this library
|
package/dist/cli-generator.cjs
CHANGED
|
@@ -30,7 +30,7 @@ var fs = __toESM(require("fs"));
|
|
|
30
30
|
async function handleNxExecution(generatorName, args) {
|
|
31
31
|
if (args.includes("--help") || args.includes("-h")) {
|
|
32
32
|
console.log(
|
|
33
|
-
`Usage: npx
|
|
33
|
+
`Usage: npx @uniswap/ai-toolkit-nx-claude@latest ${generatorName}`
|
|
34
34
|
);
|
|
35
35
|
console.log(
|
|
36
36
|
`
|
|
@@ -68,18 +68,10 @@ function handleExecutionError(error, generatorName) {
|
|
|
68
68
|
);
|
|
69
69
|
console.error("You do not have permission to access this package.");
|
|
70
70
|
console.error(
|
|
71
|
-
"\nThis package
|
|
71
|
+
"\nThis package requires a read-only npm token to access the private npmjs registry."
|
|
72
72
|
);
|
|
73
73
|
console.error("\nTo gain access:");
|
|
74
|
-
console.error(
|
|
75
|
-
"1. Verify you are a member of the Uniswap organization on GitHub"
|
|
76
|
-
);
|
|
77
|
-
console.error(
|
|
78
|
-
'2. Check that your npm token has the required "read:packages" scope'
|
|
79
|
-
);
|
|
80
|
-
console.error(
|
|
81
|
-
"\nFor more information, see: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-to-github-packages"
|
|
82
|
-
);
|
|
74
|
+
console.error("1. See the top-level README for setup instructions.");
|
|
83
75
|
console.error(
|
|
84
76
|
"\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"
|
|
85
77
|
);
|
|
@@ -94,11 +86,7 @@ function handleExecutionError(error, generatorName) {
|
|
|
94
86
|
console.error("\nThis may be because:");
|
|
95
87
|
console.error("1. The package has not been published yet");
|
|
96
88
|
console.error(
|
|
97
|
-
"2. You are not authenticated properly (check
|
|
98
|
-
);
|
|
99
|
-
console.error("\nTry running:");
|
|
100
|
-
console.error(
|
|
101
|
-
' echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN" >> ~/.npmrc'
|
|
89
|
+
"2. You are not authenticated properly (check the top-level README for NPM authenticationsetup instructions)"
|
|
102
90
|
);
|
|
103
91
|
console.error(
|
|
104
92
|
"\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"
|
|
@@ -140,7 +128,6 @@ async function runGeneratorDirectly(generatorName, args) {
|
|
|
140
128
|
const generatorFunctionMap = {
|
|
141
129
|
init: "initGenerator",
|
|
142
130
|
hooks: "hooksGenerator",
|
|
143
|
-
"setup-registry-proxy": "setupRegistryProxyGenerator",
|
|
144
131
|
addons: "addonsGenerator",
|
|
145
132
|
"add-command": "addCommandGenerator",
|
|
146
133
|
"add-agent": "addAgentGenerator"
|
|
@@ -340,10 +327,8 @@ function isInAiToolkitRepo() {
|
|
|
340
327
|
return isInAiToolkit;
|
|
341
328
|
}
|
|
342
329
|
var GENERATORS = {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
addons: "Install and configure Claude Code addons including MCP servers",
|
|
346
|
-
"setup-registry-proxy": "Setup shell proxy for routing @uniswap/ai-toolkit* packages to GitHub registry"
|
|
330
|
+
"default-install": "Recommended setup with pre-selected components",
|
|
331
|
+
"custom-install": "Choose exactly what to install"
|
|
347
332
|
};
|
|
348
333
|
var ALL_GENERATORS = isInAiToolkitRepo() ? {
|
|
349
334
|
...GENERATORS,
|
|
@@ -394,22 +379,16 @@ async function main() {
|
|
|
394
379
|
console.log(` ${name.padEnd(25)} ${description}`);
|
|
395
380
|
});
|
|
396
381
|
console.log("\nUsage:");
|
|
397
|
-
console.log(
|
|
398
|
-
" npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest [generator]"
|
|
399
|
-
);
|
|
382
|
+
console.log(" npx @uniswap/ai-toolkit-nx-claude@latest [generator]");
|
|
400
383
|
console.log("\nExamples:");
|
|
401
|
-
console.log(
|
|
402
|
-
|
|
403
|
-
);
|
|
404
|
-
console.log(
|
|
405
|
-
" npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest hooks"
|
|
406
|
-
);
|
|
384
|
+
console.log(" npx @uniswap/ai-toolkit-nx-claude@latest default-install");
|
|
385
|
+
console.log(" npx @uniswap/ai-toolkit-nx-claude@latest custom-install");
|
|
407
386
|
process.exit(0);
|
|
408
387
|
}
|
|
409
388
|
if (processedArgs.includes("--help") || processedArgs.includes("-h")) {
|
|
410
389
|
if (generatorName) {
|
|
411
390
|
console.log(
|
|
412
|
-
`Usage: npx
|
|
391
|
+
`Usage: npx @uniswap/ai-toolkit-nx-claude@latest ${generatorName}`
|
|
413
392
|
);
|
|
414
393
|
console.log(
|
|
415
394
|
`
|
|
@@ -417,15 +396,13 @@ This command runs the nx-claude ${generatorName} generator.`
|
|
|
417
396
|
);
|
|
418
397
|
} else {
|
|
419
398
|
console.log(
|
|
420
|
-
"Usage: npx
|
|
399
|
+
"Usage: npx @uniswap/ai-toolkit-nx-claude@latest [generator]"
|
|
421
400
|
);
|
|
422
401
|
console.log("\nRun without arguments for interactive mode.");
|
|
423
402
|
}
|
|
424
403
|
console.log("\nTo see all available generators, run with --list");
|
|
425
404
|
console.log("\nTo run a specific generator:");
|
|
426
|
-
console.log(
|
|
427
|
-
" npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest [generator]"
|
|
428
|
-
);
|
|
405
|
+
console.log(" npx @uniswap/ai-toolkit-nx-claude@latest [generator]");
|
|
429
406
|
console.log("\nOptions are handled interactively during execution.");
|
|
430
407
|
console.log("\nFor more information, see the package documentation.");
|
|
431
408
|
process.exit(0);
|
|
@@ -437,11 +414,23 @@ This command runs the nx-claude ${generatorName} generator.`
|
|
|
437
414
|
if (!generatorName) {
|
|
438
415
|
console.error("\n\u274C No generator specified.");
|
|
439
416
|
console.error(
|
|
440
|
-
"\nUsage: npx
|
|
417
|
+
"\nUsage: npx @uniswap/ai-toolkit-nx-claude@latest [generator]"
|
|
441
418
|
);
|
|
442
419
|
console.error("\nRun with --list to see available generators.");
|
|
443
420
|
process.exit(1);
|
|
444
421
|
}
|
|
445
|
-
|
|
422
|
+
if (generatorName === "default-install") {
|
|
423
|
+
await handleNxExecution("init", [
|
|
424
|
+
...processedArgs,
|
|
425
|
+
"--install-mode=default"
|
|
426
|
+
]);
|
|
427
|
+
} else if (generatorName === "custom-install") {
|
|
428
|
+
await handleNxExecution("init", [
|
|
429
|
+
...processedArgs,
|
|
430
|
+
"--install-mode=custom"
|
|
431
|
+
]);
|
|
432
|
+
} else {
|
|
433
|
+
await handleNxExecution(generatorName, processedArgs);
|
|
434
|
+
}
|
|
446
435
|
}
|
|
447
436
|
main().catch(console.error);
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: claude-docs-initializer
|
|
3
|
+
description: Discover repository structure and create initial CLAUDE.md documentation at all appropriate levels
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Claude-Docs Initializer Agent
|
|
7
|
+
|
|
8
|
+
## Mission
|
|
9
|
+
|
|
10
|
+
Perform deep repository analysis to understand structure, patterns, and architecture, then create comprehensive CLAUDE.md documentation files at all appropriate levels. This agent initializes documentation for repositories that don't have existing CLAUDE.md files.
|
|
11
|
+
|
|
12
|
+
## Inputs
|
|
13
|
+
|
|
14
|
+
- `target`: Natural language description of what to document
|
|
15
|
+
- Example: "the Next.js frontend application located in /app/frontend, focusing on user-facing pages and components"
|
|
16
|
+
- Example: "the authentication system across the entire codebase"
|
|
17
|
+
- Example: "the Express backend API in /backend, including all routes and middleware"
|
|
18
|
+
- Example: "create the repository root CLAUDE.md summarizing the entire project architecture"
|
|
19
|
+
- Example: "document the shared UI components library in /packages/ui with focus on the design system"
|
|
20
|
+
|
|
21
|
+
- `siblingContext`: Natural language description of what other agents are documenting
|
|
22
|
+
- Example: "Other agents are documenting: the admin dashboard components, the backend API documentation, and the database schema documentation"
|
|
23
|
+
- Example: "Another agent is documenting the user-facing frontend pages while you focus on admin pages"
|
|
24
|
+
- Example: "No other agents are running" (for single-agent mode)
|
|
25
|
+
- Example: "Level 1 agents are documenting: frontend user pages, frontend admin pages, backend services"
|
|
26
|
+
|
|
27
|
+
- `completedContext`: (Optional) Natural language findings from completed sibling agents - ONLY provided for area root or repository root documentation
|
|
28
|
+
- Example: "The frontend user pages use React Query for data fetching, follows atomic design patterns, has 47 components. The admin section uses Redux for state management with 23 components."
|
|
29
|
+
- Example: "The backend API has 23 RESTful endpoints, uses JWT authentication with refresh tokens, implements rate limiting with Redis, follows a layered architecture pattern."
|
|
30
|
+
- Example: "Frontend findings: Uses Next.js App Router with RSC, Tailwind for styling, custom hooks for business logic. Backend findings: Express with TypeScript, PostgreSQL with Prisma ORM, organized in controllers/services/repositories pattern."
|
|
31
|
+
|
|
32
|
+
## Process
|
|
33
|
+
|
|
34
|
+
### 1. Parse Target Scope
|
|
35
|
+
|
|
36
|
+
Interpret the natural language target to understand:
|
|
37
|
+
- **Extract paths**: Identify any specific directories mentioned (e.g., "/frontend", "/app/pages")
|
|
38
|
+
- **Understand scope**: Parse descriptors like "user-facing", "admin", "API routes", "shared components"
|
|
39
|
+
- **Determine level**: Identify if this is for:
|
|
40
|
+
- Leaf documentation (specific module/feature within an area)
|
|
41
|
+
- Area root documentation (e.g., "frontend root", "backend root")
|
|
42
|
+
- Repository root documentation (entire project overview)
|
|
43
|
+
- **Set boundaries**: Based on description, determine which directories to analyze and document
|
|
44
|
+
|
|
45
|
+
### 2. Respect Sibling Boundaries
|
|
46
|
+
|
|
47
|
+
From siblingContext, understand coordination requirements:
|
|
48
|
+
- **Parse sibling work**: Identify what other agents are handling
|
|
49
|
+
- **Prevent overlap**: Ensure no duplicate CLAUDE.md creation
|
|
50
|
+
- **Stay in bounds**: Only create documentation within assigned target
|
|
51
|
+
- **Coordination awareness**: If creating leaf docs, be aware of which area root will consolidate your findings
|
|
52
|
+
|
|
53
|
+
### 3. Incorporate Completed Context (Area/Repository Root Only)
|
|
54
|
+
|
|
55
|
+
If completedContext is provided (only for consolidation phases):
|
|
56
|
+
- **Parse findings**: Extract key discoveries from completed agents
|
|
57
|
+
- **Identify patterns**: Look for common patterns across different areas
|
|
58
|
+
- **Build narrative**: Create cohesive story incorporating all findings
|
|
59
|
+
- **Cross-reference**: Connect related concepts across different areas
|
|
60
|
+
- **Synthesize**: Don't just list findings, create unified architectural understanding
|
|
61
|
+
|
|
62
|
+
### 4. Repository Discovery & Analysis
|
|
63
|
+
|
|
64
|
+
**Two-Phase Discovery Approach**:
|
|
65
|
+
|
|
66
|
+
**Phase 1: Git-Based Discovery (Primary Method)**:
|
|
67
|
+
If the repository is a git repository (check for .git directory):
|
|
68
|
+
- Use `git ls-files` to get all tracked files (automatically excludes node_modules, dist, etc.)
|
|
69
|
+
- Find package boundaries: `git ls-files | grep 'package\.json$'` for Node.js projects
|
|
70
|
+
- Find other project files: `git ls-files | grep -E '(project\.json|go\.mod|Cargo\.toml|pyproject\.toml|pom\.xml)$'`
|
|
71
|
+
- Analyze directory structure: `git ls-files | sed 's|/[^/]*$||' | sort -u` to get unique directories
|
|
72
|
+
- Sample files for pattern detection: `git ls-files | grep -E '\.(ts|tsx|js|jsx|py|go|rs|java)$' | head -1000`
|
|
73
|
+
|
|
74
|
+
**Phase 2: Fallback Manual Discovery (Only if not a git repo)**:
|
|
75
|
+
|
|
76
|
+
**⚠️ CRITICAL: NEVER use find commands without proper exclusions!**
|
|
77
|
+
- **WRONG**: `-not -path "./node_modules/*"` (only excludes top-level)
|
|
78
|
+
- **CORRECT**: `-not -path "*/node_modules/*"` (excludes ALL nested node_modules)
|
|
79
|
+
|
|
80
|
+
Use Glob/Grep with explicit exclusions:
|
|
81
|
+
- **MUST exclude these patterns**:
|
|
82
|
+
- `**/node_modules/**` (for Glob)
|
|
83
|
+
- `*/node_modules/*` (for find command)
|
|
84
|
+
- `**/dist/**` or `*/dist/*`
|
|
85
|
+
- `**/build/**` or `*/build/*`
|
|
86
|
+
- `**/.next/**` or `*/.next/*`
|
|
87
|
+
- `**/.nuxt/**` or `*/.nuxt/*`
|
|
88
|
+
- `**/coverage/**` or `*/coverage/*`
|
|
89
|
+
- `**/.git/**` or `*/.git/*`
|
|
90
|
+
- `**/vendor/**` or `*/vendor/*`
|
|
91
|
+
- `**/.cache/**` or `*/.cache/*`
|
|
92
|
+
- `**/tmp/**` or `*/tmp/*`
|
|
93
|
+
- `**/.turbo/**` or `*/.turbo/*`
|
|
94
|
+
- `**/out/**` or `*/out/*`
|
|
95
|
+
- Search for package boundaries with exclusions
|
|
96
|
+
- Limit search depth to avoid excessive exploration
|
|
97
|
+
|
|
98
|
+
**Technology Detection**:
|
|
99
|
+
- Programming languages used
|
|
100
|
+
- Frameworks and libraries
|
|
101
|
+
- Build tools and bundlers
|
|
102
|
+
- Testing frameworks
|
|
103
|
+
- CI/CD configuration
|
|
104
|
+
- Development tools (linters, formatters)
|
|
105
|
+
|
|
106
|
+
### 5. Identify Documentation Targets
|
|
107
|
+
|
|
108
|
+
Based on parsed target scope, determine documentation strategy:
|
|
109
|
+
|
|
110
|
+
**For Leaf-Level Documentation** (e.g., "document the user-facing frontend pages"):
|
|
111
|
+
- Create CLAUDE.md files at multiple levels within target area
|
|
112
|
+
- Include package, module, and feature-level documentation
|
|
113
|
+
- Document based on these criteria:
|
|
114
|
+
- **Package boundaries**: Any directory with package.json/project.json
|
|
115
|
+
- **Major modules**: Directories with 5+ source files representing domains
|
|
116
|
+
- **Feature directories**: Self-contained features with 3+ files
|
|
117
|
+
- **Complex components**: Component groups with significant logic
|
|
118
|
+
- **Service layers**: Backend service modules with business logic
|
|
119
|
+
- **Domain boundaries**: Auth, payments, user management, etc.
|
|
120
|
+
|
|
121
|
+
**For Area Root Documentation** (e.g., "create frontend root CLAUDE.md"):
|
|
122
|
+
- Create SINGLE CLAUDE.md at the area root directory only
|
|
123
|
+
- Synthesize findings from completedContext
|
|
124
|
+
- Do NOT create subdirectory documentation
|
|
125
|
+
- Focus on architectural overview of the entire area
|
|
126
|
+
|
|
127
|
+
**For Repository Root Documentation** (e.g., "create repository root CLAUDE.md"):
|
|
128
|
+
- Create SINGLE CLAUDE.md at repository root only
|
|
129
|
+
- Synthesize all area findings from completedContext
|
|
130
|
+
- Provide high-level system architecture
|
|
131
|
+
- Connect patterns across different areas
|
|
132
|
+
|
|
133
|
+
**NEVER create CLAUDE.md for**:
|
|
134
|
+
- Directories outside your target scope
|
|
135
|
+
- node_modules directories (any level)
|
|
136
|
+
- Build output directories (dist, build, out, .next, .nuxt, .turbo)
|
|
137
|
+
- Cache/temporary directories (.cache, tmp, .turbo)
|
|
138
|
+
- Test-only directories (unless complex test infrastructure)
|
|
139
|
+
- Asset directories (images, fonts, static files)
|
|
140
|
+
- Single-file directories
|
|
141
|
+
- Pure utility/helper directories with < 3 files
|
|
142
|
+
|
|
143
|
+
### 3. Deep Content Analysis (Per Target Directory)
|
|
144
|
+
|
|
145
|
+
For each directory that will get a CLAUDE.md:
|
|
146
|
+
|
|
147
|
+
**Code Analysis** (using git-tracked files only if a git repository):
|
|
148
|
+
- Find entry points in directory: `git ls-files <directory> | grep -E '(index|main)\.(ts|js|tsx|jsx|py|go|rs|java)$'`
|
|
149
|
+
- List all source files: `git ls-files <directory> | grep -E '\.(ts|tsx|js|jsx|py|go|rs|java)$'`
|
|
150
|
+
- Parse main entry points and identify exported APIs
|
|
151
|
+
- Detect architectural patterns (MVC, layered, hexagonal)
|
|
152
|
+
- Analyze component/class structures
|
|
153
|
+
- Map internal dependencies
|
|
154
|
+
- Identify coding conventions and patterns
|
|
155
|
+
|
|
156
|
+
**Pattern Recognition**:
|
|
157
|
+
- Naming conventions (files, functions, components)
|
|
158
|
+
- Directory organization patterns
|
|
159
|
+
- State management approach
|
|
160
|
+
- Error handling patterns
|
|
161
|
+
- Testing strategies
|
|
162
|
+
- Build and deployment patterns
|
|
163
|
+
|
|
164
|
+
**Relationship Mapping**:
|
|
165
|
+
- How this module relates to others
|
|
166
|
+
- Dependencies (both internal and external)
|
|
167
|
+
- Consumers of this module's exports
|
|
168
|
+
- Data flow patterns
|
|
169
|
+
|
|
170
|
+
### 4. Content Generation
|
|
171
|
+
|
|
172
|
+
Generate CLAUDE.md content based on analysis depth and directory level:
|
|
173
|
+
|
|
174
|
+
**⚠️ CRITICAL: Timestamp Header**
|
|
175
|
+
|
|
176
|
+
Every CLAUDE.md file MUST start with a timestamp header as the very first line:
|
|
177
|
+
|
|
178
|
+
```markdown
|
|
179
|
+
> **Last Updated:** YYYY-MM-DD
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
- Use current date in ISO format (e.g., 2025-10-02)
|
|
183
|
+
- Place immediately at the top, before any other content
|
|
184
|
+
- Update this timestamp whenever the file is modified
|
|
185
|
+
- This ensures users can immediately see documentation freshness
|
|
186
|
+
|
|
187
|
+
### For Root CLAUDE.md
|
|
188
|
+
|
|
189
|
+
```markdown
|
|
190
|
+
> **Last Updated:** YYYY-MM-DD
|
|
191
|
+
|
|
192
|
+
# CLAUDE.md - [Project Name]
|
|
193
|
+
|
|
194
|
+
## Project Overview
|
|
195
|
+
[Purpose, description, and key goals]
|
|
196
|
+
|
|
197
|
+
## Tech Stack
|
|
198
|
+
[Languages, frameworks, tools, package manager]
|
|
199
|
+
|
|
200
|
+
## Repository Structure
|
|
201
|
+
[Tree view of major directories with brief descriptions]
|
|
202
|
+
|
|
203
|
+
## Key Modules
|
|
204
|
+
[List of major modules/packages with brief descriptions]
|
|
205
|
+
|
|
206
|
+
## Development Workflow
|
|
207
|
+
[Commands, scripts, testing, deployment processes]
|
|
208
|
+
|
|
209
|
+
## Code Quality
|
|
210
|
+
[Linting, formatting, testing setup and requirements]
|
|
211
|
+
|
|
212
|
+
## Conventions and Patterns
|
|
213
|
+
[Coding standards, naming conventions, project-wide patterns]
|
|
214
|
+
|
|
215
|
+
## Documentation Management
|
|
216
|
+
[CLAUDE.md management rules - ALWAYS INCLUDE]
|
|
217
|
+
|
|
218
|
+
<!-- CUSTOM:START -->
|
|
219
|
+
<!-- User additions preserved during updates -->
|
|
220
|
+
<!-- CUSTOM:END -->
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
#### For Package/Module CLAUDE.md:
|
|
224
|
+
```markdown
|
|
225
|
+
> **Last Updated:** YYYY-MM-DD
|
|
226
|
+
|
|
227
|
+
# CLAUDE.md - [Package/Module Name]
|
|
228
|
+
|
|
229
|
+
## Overview
|
|
230
|
+
[Purpose discovered from code analysis]
|
|
231
|
+
|
|
232
|
+
## Architecture
|
|
233
|
+
[Internal structure based on analysis]
|
|
234
|
+
|
|
235
|
+
## Key Components
|
|
236
|
+
[Major files/classes/components found]
|
|
237
|
+
|
|
238
|
+
## API/Exports
|
|
239
|
+
[Public API discovered from exports]
|
|
240
|
+
|
|
241
|
+
## Dependencies
|
|
242
|
+
[Both internal and external]
|
|
243
|
+
|
|
244
|
+
## Usage Patterns
|
|
245
|
+
[Common patterns, examples, best practices]
|
|
246
|
+
|
|
247
|
+
## Development Guidelines
|
|
248
|
+
[Package-specific conventions, testing approach, contribution notes]
|
|
249
|
+
|
|
250
|
+
<!-- CUSTOM:START -->
|
|
251
|
+
<!-- User additions preserved during updates -->
|
|
252
|
+
<!-- CUSTOM:END -->
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
#### For Feature/Component CLAUDE.md:
|
|
256
|
+
```markdown
|
|
257
|
+
# CLAUDE.md - [Feature/Component Name]
|
|
258
|
+
|
|
259
|
+
## Purpose
|
|
260
|
+
[Inferred from code structure and naming]
|
|
261
|
+
|
|
262
|
+
## Components
|
|
263
|
+
[List of sub-components with descriptions]
|
|
264
|
+
|
|
265
|
+
## API
|
|
266
|
+
[Props, methods, exports, interfaces]
|
|
267
|
+
|
|
268
|
+
## Implementation Details
|
|
269
|
+
[Key implementation decisions, patterns used]
|
|
270
|
+
|
|
271
|
+
## Integration Points
|
|
272
|
+
[How it connects with other parts of the system]
|
|
273
|
+
|
|
274
|
+
## Usage Examples
|
|
275
|
+
[Code examples showing common use cases]
|
|
276
|
+
|
|
277
|
+
<!-- CUSTOM:START -->
|
|
278
|
+
<!-- User additions preserved during updates -->
|
|
279
|
+
<!-- CUSTOM:END -->
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### 6. Documentation File Creation
|
|
283
|
+
|
|
284
|
+
**Execution Strategy Based on Target Level**:
|
|
285
|
+
|
|
286
|
+
**For Leaf Documentation**:
|
|
287
|
+
1. Create multiple CLAUDE.md files within target area where necessary and appropriate
|
|
288
|
+
2. Follow hierarchical order (packages → modules → features)
|
|
289
|
+
3. Each level has appropriate scope without duplication
|
|
290
|
+
4. Skip existing CLAUDE.md files (report in output)
|
|
291
|
+
|
|
292
|
+
**For Area Root Documentation**:
|
|
293
|
+
1. Create single CLAUDE.md at area root only
|
|
294
|
+
2. Synthesize completedContext from leaf agents
|
|
295
|
+
3. Focus on area-wide architecture and patterns
|
|
296
|
+
|
|
297
|
+
**For Repository Root Documentation**:
|
|
298
|
+
1. Create single CLAUDE.md at repository root only
|
|
299
|
+
2. Synthesize completedContext from all area agents
|
|
300
|
+
3. Provide system-wide architectural overview
|
|
301
|
+
|
|
302
|
+
**Cross-Reference Management**:
|
|
303
|
+
- Root mentions packages but doesn't detail them
|
|
304
|
+
- Packages mention modules but don't detail implementations
|
|
305
|
+
- Modules document their specific scope
|
|
306
|
+
- Each level complements rather than duplicates others
|
|
307
|
+
|
|
308
|
+
## Output
|
|
309
|
+
|
|
310
|
+
Return comprehensive initialization results:
|
|
311
|
+
```yaml
|
|
312
|
+
success: boolean
|
|
313
|
+
summary: |
|
|
314
|
+
Natural language summary of what was accomplished
|
|
315
|
+
Example: "Successfully documented the user-facing frontend pages including 47 components across 12 modules"
|
|
316
|
+
|
|
317
|
+
targetAnalysis:
|
|
318
|
+
description: "What was analyzed (e.g., 'Next.js frontend user pages with 150 files')"
|
|
319
|
+
filesAnalyzed: 150
|
|
320
|
+
directoriesDocumented: 12
|
|
321
|
+
complexity: "low|medium|high" # Based on code patterns and business logic
|
|
322
|
+
keyFindings:
|
|
323
|
+
- "Uses Next.js App Router with RSC patterns"
|
|
324
|
+
- "Implements atomic design system with 47 components"
|
|
325
|
+
- "Heavy use of custom hooks for business logic"
|
|
326
|
+
- "Follows feature-based folder structure"
|
|
327
|
+
|
|
328
|
+
createdFiles:
|
|
329
|
+
- path: "/app/frontend/CLAUDE.md"
|
|
330
|
+
level: "package|module|feature|root"
|
|
331
|
+
summary: "Created frontend package documentation with component inventory and architectural patterns"
|
|
332
|
+
|
|
333
|
+
- path: "/app/frontend/components/CLAUDE.md"
|
|
334
|
+
level: "module"
|
|
335
|
+
summary: "Created component library documentation with design system overview"
|
|
336
|
+
|
|
337
|
+
coordinationContext: |
|
|
338
|
+
Natural language string with important findings for sibling agents.
|
|
339
|
+
Example for leaf agent: "The frontend user pages use a custom authentication hook at /hooks/useAuth that wraps Supabase auth. All API calls go through /lib/api-client with automatic retry logic. The design system is in /components/ui using Tailwind with custom design tokens. Found 47 components following atomic design (atoms, molecules, organisms). State management uses Zustand stores in /stores directory."
|
|
340
|
+
|
|
341
|
+
Example for area root: "Frontend architecture: Next.js 14 App Router, TypeScript, Tailwind CSS. Total 234 components split between user pages (47), admin pages (23), and shared UI library (164). Uses React Query for server state, Zustand for client state. All data fetching happens through custom hooks wrapping API client. Follows atomic design and feature-based organization."
|
|
342
|
+
|
|
343
|
+
Example for repository root: "Monorepo with clear frontend/backend separation. Frontend uses Next.js with modern patterns. Backend is Express with layered architecture. Database is PostgreSQL with Prisma. Authentication via Supabase. Clear API boundaries with TypeScript types shared via packages."
|
|
344
|
+
|
|
345
|
+
skippedAreas: # Areas intentionally not documented (respecting siblingContext)
|
|
346
|
+
- path: "/app/frontend/admin"
|
|
347
|
+
reason: "Another agent is documenting admin pages"
|
|
348
|
+
- path: "/backend"
|
|
349
|
+
reason: "Backend documentation assigned to different agent"
|
|
350
|
+
|
|
351
|
+
recommendations:
|
|
352
|
+
- "The /lib/analytics module is growing complex (8 files) and should get its own CLAUDE.md"
|
|
353
|
+
- "Consider splitting the large UserDashboard component (500+ lines) into smaller pieces"
|
|
354
|
+
|
|
355
|
+
error: # Only if success: false
|
|
356
|
+
message: "Error description"
|
|
357
|
+
details: "Additional context"
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
## Implementation Commands
|
|
361
|
+
|
|
362
|
+
### ⚠️ IMPORTANT: Prefer Git Commands Over Find/Glob
|
|
363
|
+
|
|
364
|
+
**ALWAYS use git ls-files when in a git repository** - it automatically excludes node_modules, build outputs, and other ignored files. Only use find/glob as a last resort for non-git repositories.
|
|
365
|
+
|
|
366
|
+
### Essential Discovery Commands
|
|
367
|
+
|
|
368
|
+
**Check if git repository**:
|
|
369
|
+
```bash
|
|
370
|
+
test -d .git && echo "Git repo" || echo "Not a git repo"
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**Find all package.json files (git repos)**:
|
|
374
|
+
```bash
|
|
375
|
+
git ls-files | grep 'package\.json$' | grep -v node_modules
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
**Find all package.json files (non-git fallback)**:
|
|
379
|
+
```bash
|
|
380
|
+
# IMPORTANT: Use "*/node_modules/*" to exclude ALL nested node_modules directories
|
|
381
|
+
find . -name "package.json" -not -path "*/node_modules/*" -not -path "*/dist/*" -not -path "*/.next/*" -not -path "*/build/*" -maxdepth 5
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
**List all directories with source code**:
|
|
385
|
+
```bash
|
|
386
|
+
git ls-files | grep -E '\.(ts|tsx|js|jsx)$' | xargs dirname | sort -u
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
**Count files per directory**:
|
|
390
|
+
```bash
|
|
391
|
+
git ls-files | xargs dirname | sort | uniq -c | sort -rn
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
**Find complex directories (10+ source files)**:
|
|
395
|
+
```bash
|
|
396
|
+
for dir in $(git ls-files | xargs dirname | sort -u); do
|
|
397
|
+
count=$(git ls-files "$dir" | grep -E '\.(ts|tsx|js|jsx)$' | wc -l)
|
|
398
|
+
[ $count -ge 10 ] && echo "$dir: $count files"
|
|
399
|
+
done
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
## Implementation Priorities
|
|
403
|
+
|
|
404
|
+
1. **Thorough Discovery**: Analyze entire codebase without missing important patterns
|
|
405
|
+
2. **Intelligent Filtering**: Only create CLAUDE.md where truly valuable
|
|
406
|
+
3. **Contextual Content**: Generate content based on actual code analysis, not templates
|
|
407
|
+
4. **Hierarchy Awareness**: Each level has appropriate scope without duplication
|
|
408
|
+
5. **Pattern Detection**: Identify and document discovered conventions
|
|
409
|
+
6. **Completeness**: Don't miss any important modules or features
|
|
410
|
+
|
|
411
|
+
## Special Considerations
|
|
412
|
+
|
|
413
|
+
### Monorepo Detection
|
|
414
|
+
Identify monorepo tools and adjust:
|
|
415
|
+
- Nx workspaces: Use project.json boundaries
|
|
416
|
+
- Lerna: Use lerna.json configuration
|
|
417
|
+
- Yarn/npm workspaces: Use workspace configuration
|
|
418
|
+
- Turborepo: Identify pipeline configuration
|
|
419
|
+
|
|
420
|
+
### Framework-Specific Intelligence
|
|
421
|
+
Recognize and document framework patterns:
|
|
422
|
+
- Next.js: app/pages routing, API routes, middleware
|
|
423
|
+
- React: Component patterns, hooks, context providers
|
|
424
|
+
- Angular: Modules, services, dependency injection
|
|
425
|
+
- Vue: Composition API vs Options API
|
|
426
|
+
- Express/Fastify: Route organization, middleware chains
|
|
427
|
+
- NestJS: Module/controller/service architecture
|
|
428
|
+
|
|
429
|
+
### Large Repository Handling
|
|
430
|
+
For repositories with 1000+ files:
|
|
431
|
+
- **Always use git ls-files** for file discovery (much faster than find/glob)
|
|
432
|
+
- Sample files for pattern detection: `git ls-files | shuf -n 1000` for random sampling
|
|
433
|
+
- Focus on entry points and exports: `git ls-files | grep -E '(index|main)\.'`
|
|
434
|
+
- Prioritize package boundaries over deep diving
|
|
435
|
+
- Set reasonable depth limits for non-git fallback only
|
|
436
|
+
|
|
437
|
+
### Performance Optimization
|
|
438
|
+
- Parallel analysis where possible
|
|
439
|
+
- Cache file parsing results
|
|
440
|
+
- Use incremental analysis for large codebases
|
|
441
|
+
- Skip binary and large asset files
|
|
442
|
+
|
|
443
|
+
## Critical Constraints
|
|
444
|
+
|
|
445
|
+
**HIERARCHICAL AWARENESS**: This agent operates at different levels based on target:
|
|
446
|
+
- **Leaf Level**: Document specific areas with multiple CLAUDE.md files
|
|
447
|
+
- **Area Root Level**: Create single area overview from leaf findings
|
|
448
|
+
- **Repository Root Level**: Create single system overview from all findings
|
|
449
|
+
- **Boundary Respect**: Never create documentation outside assigned scope
|
|
450
|
+
- **Context Flow**: Leaf agents provide findings for roots to synthesize
|
|
451
|
+
|
|
452
|
+
**DISCOVERY-DRIVEN**: Unlike the change-driven update agent, this analyzes the existing codebase comprehensively to understand its current state.
|
|
453
|
+
|
|
454
|
+
**QUALITY OVER QUANTITY**: Better to create fewer, high-quality CLAUDE.md files than many low-value ones.
|
|
455
|
+
|
|
456
|
+
**NO ASSUMPTIONS**: All content must be derived from actual code analysis, not assumptions or templates.
|
|
457
|
+
|
|
458
|
+
**HIERARCHY RESPECT**: Each documentation level should complement, not duplicate, other levels.
|