add-architecture-discovery
Use when documenting project architecture — generates Technical Spec section in CLAUDE.md
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when documenting project architecture — generates Technical Spec section in CLAUDE.md
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Consolidated view of the add-pro ecosystem - commands, skills, relationships and dependencies. Loaded by /add as source of truth.
Source of truth for ADD doc rules, depth floors, IDs, refs, validation gate. Load before any doc write.
Use when running agent-judged QA validation (read-PNG by default; the playwright plugin adds live driving) — the Level C judge rubric, severity taxonomy, dual-judge (@ux-agent review ∥ @qa-agent) method, report schema/template, and the config.json/screens.json formats. Consumed by /add.qa and both judges.
Use when a state-materializing command starts or is asked to upgrade — reads the setup receipt, compares the recorded contract against the shipped one, executes the declared upgrade deltas sequentially, and rewrites the receipt even on a verified-current no-op. Consumed by /add.qa-setup STEP 1.5 and STEP 11.
Internal skill for developing ADD framework artefacts (commands, skills, agents, scripts). Use when add-framework--plan analyzes viability of new framework features, when add-framework--build implements framework artefacts, or when creating/modifying commands, skills, or agents. Always use this skill before proposing or implementing changes to the framework itself.
Use when building, styling, or theming UI components, pages, layouts, dashboards, charts, tables, or forms for SaaS products.
| name | add-architecture-discovery |
| description | Use when documenting project architecture — generates Technical Spec section in CLAUDE.md |
Analyzes the codebase and updates the Technical Spec section of CLAUDE.md with structured data in a token-efficient format.
Principle: Discover, don't impose. Document what EXISTS in the code. CLAUDE.md is self-contained. Never invent patterns. Never create separate technical-spec.md files.
Triggers: need architecture docs, update CLAUDE.md, document technical spec, /add.plan needs context, /add.build needs patterns.
Auto-loaded by: /add.plan, /add.build.
.codeadd/wiki/ already current and CLAUDE.md Technical Spec reflects the codebaseRun: bash .codeadd/scripts/architecture-discover.sh → .claude/temp/architecture-discovery.md
Collects: {"includes":["package.json","turbo.json","tsconfig","dir structure depth 3","stack detection","patterns (CQRS,Repository,DI)","controllers,services,repositories","frontend (UI,state,forms,stores,hooks)","workers,cron,events,webhooks","integrations","statistics"]}
Read the discovery document COMPLETE before any manual searches — primary source (90% of work).
Generate the dependency contract BEFORE Technical Spec. Output → CLAUDE.md → ## Architecture Contract.
Steps:
package.json to map internal dependenciesHierarchy detection:
When discovery doc has insufficient info, read 1–2 files per area for STRUCTURE only — implementation details belong in {{addpath:wiki/domains/}}.
| Area | Question |
|---|---|
| Services | Interface pattern? |
| Repositories | Return Entity or DTO? |
| Workers | Dispatch/retry config? |
| Cron | Interval pattern? |
| Events | Naming pattern? |
| Webhooks | Signature verify? |
Classify each app/package to dispatch the appropriate specialist. Method: read package.json deps → match signals → return type.
| Type | Dependencies |
|---|---|
| backend | express, fastify, nestjs, @nestjs/, hono, koa, @grpc/, socket.io, @trpc/* |
| frontend | react, vue, svelte, solid-js, @angular/, next, nuxt, @tanstack/react-, @remix-run/* |
| database | prisma, drizzle-orm, kysely, typeorm, sequelize, knex, @mikro-orm/* |
| cli | commander, yargs, clack, @clack/*, inquirer, meow, oclif |
| worker | bullmq, bull, agenda, node-cron, bee-queue, @temporalio/* |
Rules: an app can have MULTIPLE types; primary = first strong match; no signals → generic.
Output → {{addpath:wiki/domains/}} for area specialists; the spine analyzer writes to {{addpath:wiki/}} root. Naming: lowercase area type.
| Type | Skill | Output | Analyzes |
|---|---|---|---|
| spine | spine-analyzer.md | wiki/architecture.md, wiki/conventions.md, wiki/workflows.md | cross-cutting: system shape/boundaries, project-wide conventions, dev workflows & validation gates |
| backend | backend-analyzer.md | wiki/domains/backend.md | logging, validation, error handling, auth, middleware, API patterns |
| frontend | frontend-analyzer.md | wiki/domains/frontend.md | state, styling, components, forms, hooks, routing |
| database | database-analyzer.md | wiki/domains/database.md (cross-app) | ORM, migrations, queries, transactions |
| cli | — | wiki/domains/cli.md | commands, args, prompts (generic template) |
| worker | — | wiki/domains/worker.md | jobs, queues, scheduling (generic template) |
| generic | — | wiki/domains/[area-type].md | structure, config, entry points only |
Dispatch: spine analyzer runs ONCE, ALWAYS, regardless of app classification; one area specialist per app (primary type); database analyzer runs ONCE cross-app; apps without specialist → generic; ALL run in PARALLEL (single dispatch batch, spine included).
For ANY app type without a specialist. Sections: App Nature, Structure, Entry Points, Dependencies, Configuration, Reusable Abstractions, Project Conventions, Commands/Jobs.
Reusable Abstractions — HIGHEST PRIORITY. Discover base classes, shared utilities, custom helpers, existing services agents MUST reuse. List path + purpose + usage example.
Project Conventions — HIGHEST PRIORITY. Discover file naming, folder organization, module registration, import conventions, where new code goes.
Rules: discover via code not name; include real examples; skip empty sections; prioritize Reusable Abstractions and Project Conventions over library configs.
Detect runnable commands for 5 universal gate intents — lint, typecheck, test, build, format — across ANY language/ecosystem.
Output → CLAUDE.md → ## Validation Gates (minified JSON), placed after ## Technical Spec, before ## Implementation Patterns.
Language-agnostic. Inspect manifests the project actually has — package.json, pyproject.toml, *.csproj/*.sln, Makefile, Cargo.toml, go.mod, mix.exs, composer.json, Gemfile, build.gradle, pom.xml, etc. Map each intent to the real command. Do NOT assume language; do NOT fabricate gates.
| Intent | Meaning |
|---|---|
| lint | static analysis / style (eslint, ruff, golangci-lint, rubocop, dotnet format --verify) |
| typecheck | type validation when separate from build (tsc --noEmit, mypy, pyright, mix dialyzer) |
| build | compile / bundle / produce artifacts (npm run build, cargo build, dotnet build, go build, mvn package) |
| test | automated test suite (npm test, pytest, go test, cargo test, dotnet test, mix test) |
| format | formatter in CHECK mode only (prettier --check, ruff format --check, gofmt -l, dotnet format --verify-no-changes) |
test over test:e2e)format: ONLY non-mutating variants (--check, --verify, -l). Mutating-only format/fmt → SKIPverify), still emit each gate when individually runnable## Validation Gates
{"validation_gates":{"lint":"<cmd>","typecheck":"<cmd>","test":"<cmd>","build":"<cmd>","format":"<cmd>"}}
If NO gates detected → omit the section (do not emit empty object).
{"format":"JSON minified one-line","max":"10 words per description","sections":["Stack","Structure","Patterns","Domain","API Routes","Critical Files","Background Processing","Scheduling","Events","Webhooks","Validation Gates"]}
Skip sections that don't apply. Update WITHIN CLAUDE.md.
Every analyzer in this registry (spine + area specialists) writes pages that satisfy this contract. Analyzer-specific sections below reference this one, they never restate it.
---
type: reference | how-to | explanation
area: backend | frontend | database | architecture | conventions | workflows | <domain>
description: <1-2 sentences, keyword-rich — what this page covers and when to read it>
sources: [src/server/**, libs/database/src/repos/**] # ≤8 globs, must cover every path cited in the page
commit: <short-sha at generation/last update of THIS page>
generated: <YYYY-MM-DD of THIS page's last write>
tags: [<grep targets: di, repository-pattern, error-handling>] # ≤6
---
# <Title>
## TL;DR
<2-4 lines: what this page is, why it exists, headline facts.>
## TOC ← required when page > 100 lines
- [Topic A](#topic-a) ...
## <Topic — topic sentence first>
<Extractive content. Every non-trivial claim carries a source ref `path/file.ts:42`.
Real code examples, one per topic, trimmed.>
## Related
- [domains/database.md](database.md): <why related> ← 2-4 links, relative paths
path:line). No invented modules, APIs, or behavior.[[page]].wiki/domains/<area>/ subdirectory only once a page exceeds the cap — never preemptively..codeadd/wiki/ = HOW to implement (patterns, conventions, workflows, architecture rationale)CLAUDE.md no longer carries a hand-written ### Implementation Patterns block — that section is REPLACED by the codeadd-wiki managed block, owned by /add.wiki STEP 6 (see {{skill:add-claude-md-style/SKILL.md}}). This skill's analyzers only produce the wiki pages; they do not write the managed block themselves.
rm .claude/temp/architecture-discovery.md after execution.
Report discoveries + suggest /add.wiki if .codeadd/wiki/ doesn't exist.
## Architecture Contract
> Dependencies and placement. Consult BEFORE implementing/reviewing.
### Layers
{"hierarchy":"domain → interfaces → database → api","rule":"inner never imports outer"}
### Packages
{"domain":"@org/domain","interfaces":"@org/backend","database":"@org/database","api":"apps/*"}
### Imports
{"domain":[],"interfaces":["domain"],"database":["domain","interfaces"],"api":["*"]}
### Placement
{"Entities":"domain","Enums":"domain","ServiceContracts":"interfaces","DTOs.shared":"interfaces","Repositories":"database","Services":"api","Handlers":"api"}
## Technical Spec
> Token-efficient format for AI consumption.
**Generated:** YYYY-MM-DD | **Type:** [Monorepo|SingleApp]
### Stack
{"pkg":"[npm|yarn|pnpm]","build":"[turbo|nx]","lang":"[typescript|python]"}
{"backend":{"framework":"[NestJS|Express|Django]","version":"X.Y.Z"}}
{"frontend":{"framework":"[React|Vue|Next]","version":"X.Y.Z"}}
{"database":{"engine":"[PostgreSQL|MySQL]","orm":"[Kysely|Prisma]"}}
### Structure
{"paths":{"backend":"path","frontend":"path","domain":"path"}}
### Patterns
{"identified":["CQRS","Repository","DI"]}
{"conventions":{"files":"kebab-case","classes":"PascalCase"}}
### Domain
{"models":["entity1","entity2"],"location":"path"}
### API Routes
{"globalPrefix":"/api/v1","prefixLocation":"path"}
{"routes":[{"module":"auth","prefix":"/auth","endpoints":["POST /login"]}]}
### Validation Gates (if any detected — see Validation Gates Detection above)
{"validation_gates":{"lint":"<command>","typecheck":"<command>","test":"<command>","build":"<command>","format":"<command-in-check-mode>"}}
### Project Knowledge Base (CLAUDE.md managed block — NOT written by this skill)
{"note":"CLAUDE.md carries a codeadd-wiki managed block instead of a hand-written Implementation Patterns section"}
{"owner":"/add.wiki STEP 6 + add-claude-md-style — see that skill for the block template"}
{"location":".codeadd/wiki/","entrypoint":".codeadd/wiki/index.md"}
{"generate":"Run /add.wiki to create or refresh the wiki"}