skills/define-architecture/SKILL.md
Generates folder structures, module contracts, middleware pipelines, and frontend/backend boundaries for TypeScript full-stack applications, and finds domain-informed deepening opportunities in existing codebases. Use when setting up project structure, organizing a monorepo, defining folder layout, designing backend modules, establishing team conventions, improving architecture outside a local diff, writing an architecture brief, or asking "how should I structure this app", "design the folder structure", "set up the architecture", "find architecture improvements", "make this codebase agent-friendly", or "set up guardrails for coding agents". For scaffolding a new Next.js repo use scaffold-nextjs, for a new TypeScript CLI use scaffold-cli, for multi-tenant domain or isolation strategy use multi-tenant-architecture, and for structural review of a local diff use pr-reviewer.
npx skillsauth add mblode/agent-skills define-architectureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Define durable, easy-to-change architecture defaults for TypeScript full-stack apps; produce an enforceable architecture brief.
scaffold-nextjs for a Next.js turborepo, scaffold-cli for a TypeScript CLI), multi-tenant domain/isolation/routing (multi-tenant-architecture), or structural review of a local diff (pr-reviewer).Track this checklist:
Architecture progress:
- [ ] Step 1: Pick workflow (new codebase: Setup; existing: Adoption)
- [ ] Step 2: Run it end to end
- [ ] Step 3: Write the brief (Output template)
- [ ] Step 4: Run Validation loop, record results in brief
- [ ] Step 5: Fix failed checks, re-run loop
Load references only when the condition applies:
| Reference | Read when | |-----------|-----------| | references/stack-defaults.md | Choosing libraries, tooling, or deploy targets | | references/api-design.md | Designing endpoints, module contracts, or request context; reviewing API surface changes | | references/distributed-correctness.md | Designing flows that call external systems, consume webhooks, retry, need an audit trail, or move money (billing, credits, payouts) | | references/deepening-existing.md | Running the Adoption workflow (domain mapping, opportunity patterns, output template) | | references/craftsmanship.md | Writing the team-conventions, testing, or quality-bar sections | | references/agent-friendly-codebase.md | Preparing a codebase for coding agents: guardrail tooling, invariant ratchets, legacy markers, generated contracts, verification tiers | | references/shipping-practices.md | Writing the rollout and rollback section |
apps/ for deployable surfaces (api, web, admin).packages/ for shared libraries (shared, ui, icons, auth, proto).handler: transport only.service: business orchestration.dao: database access only.mapper: DB/proto/domain transformations.constants and types: module-local contracts.tenantId, userId, and traceId in an AsyncLocalStorage-backed RequestContext, initialized in every entrypoint (RPC, HTTP, jobs, CLI) and read via getContext(); never thread a ctx parameter through business functions. Implementation in references/api-design.md."use client" only at leaf components needing interactivity.useState or sync two stores with useEffect; both are the red flag that ownership is unclear.Goal: domain-informed deepening, not a rewrite. Load references/deepening-existing.md for the analysis method, opportunity patterns, and output template.
CONTEXT.md, docs/adr/, or local equivalents if present, then read the code for entities, actions, and bounded contexts as the team names them. Note divergence (one concept, three names; or one name, three concepts).Run before finalizing; record results in the brief (Open risks). Each check needs evidence; "looks consistent" is not a pass.
npm run lint, npm run check-types, npm run test --workspace=<pkg> or equivalents). Evidence: passing output.On failure: fix the brief or conventions, then re-run the loop.
Use this structure:
# Architecture brief
## Context and constraints
## Repo shape
## Backend module contracts
## Request context and middleware policy
## Frontend boundaries
## Testing strategy
## Quality bar and surface-area budget
## Rollout and rollback plan
## Open risks and follow-ups
scaffold-nextjs or scaffold-cli: scaffold the repo once the brief is agreed.multi-tenant-architecture: tenant identification, isolation, and domain strategy.pr-reviewer: structural review of a local diff once implemented.planning: turn an Adoption opportunity into an implementation plan, then stress-test it.agents-md: audit and refactor the AGENTS.md file itself; this skill decides what belongs in tooling instead.tidy: diff-scoped cleanup pass; references/agent-friendly-codebase.md covers the repo-wide guardrail setup that keeps those passes small.package.json: hoisting hides missing declarations, so an app builds locally but breaks deploying alone. Each app owns its deps.dao may not import handler) the day you write it."use client" at page or layout level: it converts the whole subtree to client rendering and forfeits streaming and direct server data access. Push it to leaves.packages/ early: wait until 3+ apps need the same code; a premature shared package couples release cycles for nothing.references/distributed-correctness.md.references/agent-friendly-codebase.md).development
Fans out four concurrent review agents over the current diff, then APPLIES fixes directly to the working tree and verifies the build. Mutates code; it does not produce a report. Covers reuse (duplicate logic, hand-rolled stdlib, reinvented platform features), quality (hacky patterns, React/TypeScript hygiene, over-memoisation, exhaustive-deps, `any`, dead code, `CLAUDE.md`/`AGENTS.md` violations), efficiency (unnecessary work, missed concurrency, hot-path bloat), and test discipline (bug fixes without a repro test, useless tests to delete, missing tests only when they prevent a named failure). Use when the user says "tidy this up", "simplify", "clean up this diff", "polish my changes", "check for duplication", or "any reuse opportunities?", i.e. when the intent is to have the changes made automatically. For a read-only report that lists findings without touching files, use `pr-reviewer` instead. This skill edits code; for the PR's title, description, or commit history, use `pr-creator`.
development
Decides what an interface should do before UI is built or audited: interaction choice, action scope and consequence, reachable states, resilience, and accessibility as task completion. Works from a brief, spec, mockup, intent, or existing UI. Use when asked "is this the right interaction", "design the flow", "what control should this use", "what should this action affect", "which states should this have", "make this resilient", or "what breaks here". For building or styling use ui-design; for built-code audits use ui-audit; for copy wording use copywriting.
development
Builds and stress-tests implementation plans in two modes. Create mode scans code and docs, asks one question at a time with a recommended answer, runs a blindspot pass when the user is new to the area, then writes a plan file. Review mode scores completeness, feasibility, scope, testability, risk, and assumptions, verifies checkable claims, and writes resolutions back until every dimension reaches 5/5. Use when asked to "create a plan", "plan this feature", "I want to build X", "grill me", "think this through", "blindspot pass", "unknown unknowns", "this is new to me", "review my plan", "rubber duck this", "stress test this plan", "is this plan ready", "get this plan to 5/5", "what am I missing", "verify this claim", "prove this plan", "fact-check this plan", or when the user explicitly wants a plan artifact before implementation. For code review use pr-reviewer; for architecture briefs use define-architecture.
tools
Audits the smallest relevant developer-facing surface of a library, CLI, SDK, or npm package across API contracts, errors, CLI behavior, public types, onboarding, and config. Uses candidate-first rule loading, bounded local evidence, and compact root-cause findings. Use when asked to "audit my CLI", "make this CLI agent-friendly", "is this API ergonomic", "review the developer experience", "improve these errors", "simplify first run", or "review my SDK". For end-user UI use ui-audit, for agentic-app trust use ax-audit, for docs prose use docs-writing, for README work use readme-creator, and for repo architecture use define-architecture. Inside a product that also ships a UI, this is the skill for the developer-facing half, so pick it when the complaint is about an import, command, error string, exported type, or config rather than a screen.