codebase-architecture
Designs module interfaces, deepens shallow modules, and installs enforceable repository guardrails and agent wayfinding.
Skill by mblode
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/mblode-codebase-architecture
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: design, agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/codebase-architecture
What's inside
- Skill name
codebase-architecture- Description
- Designs module interfaces, deepens shallow modules, and installs enforceable repository guardrails and agent wayfinding. Use when asked to "design the architecture", "simplify our modules", "find shallow modules", "harden the repo", "gate an unattended agent fix job", or "triage alerts with an agent".
- License
- MIT
- Instructions
- 184 lines in SKILL.md · view on GitHub
Files (16)
- SKILL.md
- evals.json · evals/
- evaluation-scenarios.md · evals/
- agent-runtime.md · references/
- api-design.md · references/
- brief-conventions.md · references/
- contagion-markers.md · references/
- deepening-existing.md · references/
- distributed-correctness.md · references/
- domain-language.md · references/
- enforcement-ladder.md · references/
- guardrail-tooling.md · references/
- stack-defaults.md · references/
- verification-tiers.md · references/
- vocabulary.md · references/
- wayfinding.md · references/
SKILL.md (first lines)
# Codebase Architecture Decide a TypeScript codebase's structure, improve it where change has become expensive, and make it hold. The target is a codebase a reader can hold in their head: few surfaces, one canonical way to do each job, and behaviour where you would first look for it. - **IS:** folder structures, module interfaces, request context and middleware pipelines, frontend/backend boundaries; architecture briefs; domain language and decision records; domain-informed deepening; guardrail tooling, CI gates, and agent wayfinding. - **IS NOT:** scaffolding a new repo (`scaffold-nextjs` for a Next.js turborepo, `scaffold-cli` for a TypeScript CLI), multi-tenant domain/isolation/routing (`multi-tenant-architecture`), the content of AGENTS.md itself (`agents-md`), a plan for one feature (`planning`), a diff-scoped cleanup pass (`tidy`), structural review of a local diff (`tidy`), or a product's own verify CLI, doctor command, and feature map (`app-verification`, call it by name). ## Contents - Modes - References - Design mode (new codebase) - Deepen mode (existing codebase) - Harden mode (make it stick) - Validation loop - Output template - Gotchas - Related skills ## Modes Pick by the problem, not by the artifact, and say which you picked. | Mode | You are here when | Output | |------|-------------------|--------| | **Design** | Starting a new app, service, or surface, and the structure is not decided yet | An architecture brief | | **Deepen** | The code works, but change is expensive: concepts scattered, seams leaking, one idea under three names | Ranked opportunities, then one migrated slice | | **Harden** | The structure is decided and keeps decaying, or agents keep doing the wrong thing in this repo | Wired checks, markers, and recipes | **Modes compose, and running more than one is normal.** Design ends in Harden, because a contract with no check is a suggestion. Deepen ends in Harden, so the new seam cannot decay back. Harden runs alone when the structure is already right and only the enforcement is missing, which is the common case in a repo that agents work in. **When two look equally right, prefer Deepen.** "Agents keep using the old pattern" sounds like Harden, but if the cause is one concept living in two places, quarantine only freezes the duplicate: Deepen deletes it and Harden holds the line until that lands. Harden alone is right when the old thing genuinely has to stay. **When you cannot write to the repo** (no checkout, read-only request, or a question rather than a change), each mode's output degrades to its plan: the brief, the ranked opportunities, or the named checks with their rungs. Say which checks remain unproven, since none of them are wired. **As simple as possible, no simpler.** Every mode cuts: surfaces in Design, concepts in Deepen, dual paths and dormant config in Harden. The floor does not get cut: validation at trust boundaries, error handling that prevents data loss, security, accessibility, observability on anything deployed, and whatever was explicitly asked for. A simplification that reaches one of those is a bug. Where a corner is cut on purpose, mark it with its ceiling and upgrade path rather than leaving the next reader to guess whether it is finished. Copy this to track progress, and delete the lines for modes you are not running: ```text Codebase architecture progress: - [ ] Modes chosen and stated (Design / Deepen / Harden) - [ ] Design: assumptions stated, repo shape, every contract names its check, brief written - [ ] Deepen: git hot spots, glossary, ranked opportunities with paths, one slice migrated - [ ] Harden: existing checks surveyed, checks picked by failure, each landed green and proven to bite - [ ] Validation loop run for the modes used; evidence recorded, N/A items named ``` ## References Load only when the condition applies. | Reference | Mode | Read when | |-----------|------|-----------| | [references/vocabulary.md](references/vocabulary.md) | All | Before naming a module, interface, seam, or adapter in any output; it defines the deletion test | | [references/stack-defaults.md](references/stack-defaults.md) | Design | Choosing libraries, tooling, or deploy targets | | [references/api-design.md](references/api-design.md) | Design, Deepen | Designing endpoints, module interfaces, request context, error shapes, or forwarded credentials | | [references/distributed-correctness.md](references/distributed-correctness.md) | Design, Deepen | The work provably touches an external system, webhook, retry, audit trail, or money. In Deepen you can grep for it; in Design it is a question about requirements, so confirm before loading rather than inferring it from the product's domain | | [references/brief-conventions.md](references/brief-conventions.md) | Design | Writing the conventions, testing, quality-bar, or rollout and rollback sections of the brief | | [references/deepening-existing.md](references/deepening-existing.md) | Deepen | Running Deepen: opportunity patterns, design it twice, ranking, measuring an agent-facing change, output template | | [references/domain-language.md](references/domain-language.md) | Deepen | Writing or fixing a glossary, resolving naming divergence, recording a decision | | [references/enforcement-ladder.md](references/enforcement-ladder.md) | Harden | Adding any check to a repo that already violates it | | [references/guardrail-tooling.md](references/guardrail-tooling.md) | Harden | Choosing and wiring the actual checks: dead code, duplication, cycles, module and package boundaries, file size, staleness gates | | [references/wayfinding.md](references/wayfinding.md) | Harden | Agents cannot find things, or keep re-deriving the same path | | [references/contagion-markers.md](references/contagion-markers.md) | Harden | The repo has legacy, generated, dual-path, or deliberately simplified code | | [references/verification-tiers.md](references/verification-tiers.md) | Harden | Defining which commands an agent should run, and when | | [references/agent-runtime.md](references/agent-runtime.md) | Harden | Configuring the post-edit hook, the permission allowlist, or a job where an agent drafts fixes or triages alerts unattended | ## Design mode (new codebase) Before any of this, ask whether each surface needs to exist. A module, service, app, or entrypoint that could be a folder in something that already ships is the cheapest architecture decision available, and the only one that stays cheap. Every surface you do accept pays the relationship cost in the surface-area budget (`brief-conventions.md`): name its owner, tests, observability, and deletion path before it goes in the brief. 1. Constraints first: product scope, team size, compliance/security, expected scale, deploy targets, required integrations, and quality bar. A one-line request supplies none of these, so assume the common case, state every assumption in the brief's first section, and invite correction. Ask outright only where a wrong guess would restructure the brief rather than extend it, which in practice is multi-tenancy and whether the API is public. 2. Choose repo shape: - `apps/` for deployable surfaces (`api`, `web`, `admin`). - `packages/` for shared libraries (`shared`, `ui`, `icons`, `auth`, `proto`). 3. Define backend module interfaces, each naming its enforcement (import-boundary lint or type check): - `handler`: transport only. - `service`: business orchestration. - `dao`: database access only; only DAOs import the db package, and each table has one owning module whose service is the only writer. Query rules in [references/api-design.md](references/api-design.md), "Data Access". - `mapper`: DB/proto/domain transformations. - `constants` and `types`: module-local contracts. 4. Define request context and middleware: - Carry `tenantId`, `userId`, and `traceId` in an AsyncLocalStorage-backed `RequestContext`, initialized in every entrypoint (RPC, HTTP, jobs, CLI) and read via `getContext()`. A threaded `ctx` parameter grows every signature, and adding one field later touches every call site. Implementation in [references/api-design.md](references/api-design.md). - Require an explicit auth policy per RPC method at registration; a method without one fails registration rather than defaulting to open. - Keep auth, logging, errors, and context in shared middleware, not per-handler code. 5. Define frontend boundaries (Next.js App Router default): - `app/` holds routing files only (`page`, `layout`, `loading`, `error`, `route`). Domain code lives in `src/modules/<name>/` behind its root files; UI private to one route goes in a `_components/` folder beside its page. A page that grows logic moves it to a module, not to a sibling file in `app/`. - Server Components by default; `"use client"` at the interactive leaves. Where a client wrapper needs server-rendered content, pass it in as `children`. - Server state in TanStack or Connect Query; client state in component state; MobX only for cross-cutting client state that fits neither. Each piece of data has one owner: server data mirrored into `useState`, or two stores synced with `useEffect`, is the sign that ownership is unclear. - `proxy.ts` (Next 16's name for `middleware.ts`) handles redirects, rewrites, and headers. Authorization is decided inside each route handler and Server Function, because a matcher-excluded path skips the proxy and Server Functions post to their page's route. 6. Testing and release: - Unit tests stay DB-free; integration/E2E run in parallel with dynamically generated IDs so runs never collide on fixtures. - Release in small, complete, reversible vertical slices with a rollback plan per change. - A slice is complete only when reliability, error paths, observability, and user-facing states are covered; deferring them to a polish pass is how they never ship. 7. Every contract in the brief names the lint rule, type check, or test that catches its violation, then continue into Harden mode to wire them. ## Deepen mode (existing codebase) Goal: domain-informed deepening, not a rewrite. Load [references/deepening-existing.md](references/deepening-existing.md) for the analysis method, opportunity patterns, and output template. 1. **Map the domain language and decisions.** Read `CONTEXT.md`, `docs/adr/`, or local equivalents if present, then read the code for entities, actions, and contexts as the team names them. Note divergence (one concept, three names; or one name, three concepts). Format and ADR rules in [references/domain-language.md](references/domain-language.md). 2. **Scope the scan by where change lands.** Deepening pays off on code that keeps changing, so `git log --oneline` over a good stretch of history first and weight the files that keep coming up. An unscoped scan drifts into speculative cleanup. 3. **Find deepening opportunities.** Look for anemic concepts, shallow modules, leaking seams, naming divergence, duplicated concepts, primitive obsession, misplaced logic, and tests forced past the public interface. Record each with file paths, never a vague smell. Check deletion first on every candidate: a concept with no live caller, a flag whose branch never runs, a layer with one implementation. Deleting it is the deepening, and it is the only move that cannot make the codebase harder to read. 4. **Rank by leverage.** Prefer opportunities that pass the deletion test, localize named future changes, have low churn, meet a current requirement, and have a viable testing seam. Rank candidates before designing target interfaces; drop speculative cleanups. For the top candidate, design the interface twice before picking one. 5. **Migrate one vertical slice first.** Prove the highest-leverage move end to end through one slice before generalizing. 6. **Enforce the new seam** with lint, type, or test checks so it cannot decay, then roll out module by module. Continue into Harden mode for the enforcement rung and the check-bites test. ## Harden mode (make it stick) Two halves: **guardrails** stop the wrong thing landing, **wayfinding** makes the right thing cheap to find. Both exist because agents arrive by grep, not by reading docs, so the warning has to live where they land and the rule has to be an exit code rather than a sentence someone might recall. Reach for the strongest mechanism first: structure, then lint and CI, then prose, then human review; every review comment, incident, or repeated mistake is a missing check ([references/enforcement-ladder.md](references/enforcement-ladder.md)). Steps 1 to 3 always run. Steps 4 to 6 run only when their condition holds, and a request to add one check stops at step 3. Running all six for every request loads most of the bundle and is the failure this mode is most prone to. 1. **Survey what exists.** Package scripts, CI steps, hook config, lint config, the instruction file, the docs index. Find three things: checks that run locally but do not gate the merge, checks that run in CI but cannot fail (`verification-tiers.md`, "Commands that lie"), and dormant config nobody invokes. Wire the first, fix the second, delete the third ([references/contagion-markers.md](references/contagion-markers.md)). 2. **Choose checks by the failure they prevent**, never by tool popularity. Categories and tools in [references/guardrail-tooling.md](references/guardrail-tooling.md). Pick the two or three failures this repo actually exhibits; installing the full set at once forces the weakest enforcement rung on all of them. 3. **Install each check:** pick an enforcement rung for the violations that already exist ([references/enforcement-ladder.md](references/enforcement-ladder.md)), ship it green, then prove it bites (run it, break it on purpose, watch it fail with a message naming the fix, revert). Wire it into both a pre-commit hook and CI.
From mblode/agent-skills, MIT.
More from mblode/agent-skills
- 0.791score
agent-ready
mblode
Implements agent-readiness on public sites and docs from Mintlify Agent Score, AFDocs, Is Agentic, Is It Agent Ready, or url-discovery-bench reports, or from…
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
agent-skills-creator
mblode
Creates and improves portable Agent Skills with a validator, routing scenarios, and evidence-based keep, cut, merge, or retire decisions.
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
agents-md
mblode
Audits and edits agent instruction files, verifies repository commands, and migrates repositories to AGENTS.md as the single shared source.
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
autoship
mblode
Runs a changesets npm release through the version PR, CI publish, and registry verification.
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
ax-audit
mblode
Audits agentic products for tool parity, authority, approval payloads, recovery, and trust using 24 rules and a ship verdict.
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
chat-history
mblode
Recovers decisions, previous fixes, research, and what followed a prompt from past AI conversations, with source evidence.
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
ci-speedup
mblode
Speeds up CI and the merge path: finds where changes wait between push and deploy, then fixes the critical path, check placement, merge queue or post-merge…
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
dx-audit
mblode
Audits libraries, CLIs, and SDKs using 38 rules for public contracts, package exports, piped output, errors, and configuration.
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
eli5
mblode
Picks the form that explains best and applies the house explanation style: plain prose, controlled English modelled on ASD-STE100, a diagram, an interactive…
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
ghostwriter
mblode
Writes, rewrites, and critiques messages, posts, review comments, tickets, PRDs, design docs, talk scripts, docs, READMEs, and copy as the user or their…
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
multi-tenant-architecture
mblode
Designs tenant isolation, hostname routing, custom-domain lifecycle, and plan limits on Cloudflare or Vercel.
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
planning
mblode
Creates and reviews executable implementation plans grounded in repository evidence, with vertical slices, explicit decisions, and verification criteria.
SkillAFreshness: A★ 162Claude Code +9
Signals
- Stars
- 162
- Forks
- 14
- Open issues
- 0
- Last commit (this folder)
- Oct 22, 2026 (5 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/mblode/agent-skills
- Website
- blode.co/agent-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from mblode
- 0.791score
agent-ready
mblode
Implements agent-readiness on public sites and docs from Mintlify Agent Score, AFDocs, Is Agentic, Is It Agent Ready, or url-discovery-bench reports, or from…
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
agent-skills-creator
mblode
Creates and improves portable Agent Skills with a validator, routing scenarios, and evidence-based keep, cut, merge, or retire decisions.
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
agents-md
mblode
Audits and edits agent instruction files, verifies repository commands, and migrates repositories to AGENTS.md as the single shared source.
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
autoship
mblode
Runs a changesets npm release through the version PR, CI publish, and registry verification.
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
ax-audit
mblode
Audits agentic products for tool parity, authority, approval payloads, recovery, and trust using 24 rules and a ship verdict.
SkillAFreshness: A★ 162Claude Code +9 - 0.791score
chat-history
mblode
Recovers decisions, previous fixes, research, and what followed a prompt from past AI conversations, with source evidence.
SkillAFreshness: A★ 162Claude Code +9
Cite this page
codebase-architecture skill. Agent Mart. https://agentmart.dev/skills/mblode-codebase-architecture (last updated 2026-10-24)