dist/codex/plugins/dev-workflow/skills/improving-codebase-architecture/SKILL.md
Find deepening opportunities in a codebase, informed by the domain language in CONTEXT.md and the decisions in docs/adr/. Use when the user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more testable and AI-navigable. NOT for line-level cleanup (use reviewing-code) or batch edits (use refactoring-code).
npx skillsauth add alexei-led/claude-code-config improving-codebase-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.
Surface architectural friction and propose deepening opportunities — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.
This skill produces a candidate list and an agreed design, not edits. Both roles run it the same way; the difference is what happens after DESIGN AGREED:
refactoring-code to apply.Detect the language from the file extensions in scope and load the matching reference for language-specific deepening patterns:
Mixed languages: load each matching reference. Unknown language: use the language-agnostic vocabulary and process below only.
reviewing-code, refactoring-code, or normal editing, and keep scope limited to the requested cleanup if proceeding.Use the module-depth vocabulary exactly in every suggestion — module, interface, implementation, depth, seam, adapter, leverage, locality — plus the deletion test, the interface-is-the-test-surface principle, and the one-adapter-vs-two seam rule. Full definitions and the complete principle list are in LANGUAGE.md; read it before naming candidates. Don't drift into "component," "service," "API," or "boundary."
This skill is informed by the project's domain model. The domain language gives names to good seams; ADRs record decisions the skill should not re-litigate.
Read the project's domain glossary (CONTEXT.md / CONTEXT-MAP.md) and any ADRs in docs/adr/ for the area you're touching first. If the project uses brainstorming-ideas-style domain docs, that's where vocabulary and decisions live.
Then use the Agent tool with subagent_type=Explore to walk the codebase. Don't follow rigid heuristics — explore organically and note where you experience friction:
Apply the deletion test to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.
Present a numbered list of deepening opportunities. For each candidate:
Use CONTEXT.md vocabulary for the domain, and LANGUAGE.md vocabulary for the architecture. If CONTEXT.md defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
If a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly (e.g. "contradicts ADR-0007 — but worth reopening because…"). Don't list every theoretical refactor an ADR forbids.
Do NOT propose interfaces yet. Ask the user: "Which of these would you like to explore?"
Once the user picks a candidate, drop into a grilling conversation (see the brainstorming-ideas skill's references/grill-protocol.md for the interview discipline). Walk the design tree with them — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.
Side effects happen inline as decisions crystallize:
CONTEXT.md? Add the term to CONTEXT.md with a tight one-sentence definition, same discipline as brainstorming-ideas. Create the file lazily if it doesn't exist.CONTEXT.md right there.docs/adr/, framed as: "Want me to record this as an ADR so future architecture reviews don't re-suggest it?" Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones.CONTEXT.md or ADRs found → proceed with exploration; note the absence; do not invent domain vocabulary.reviewing-code or refactoring-code and stop using architecture terminology.ARCHITECTURE CANDIDATES
=======================
1. Files: <list>
Problem: <friction description>
Solution: <plain-English change>
Benefits: locality — <how>; leverage — <how>; tests — <how>
2. ...
Which of these would you like to explore?
After the grilling loop resolves a candidate, output a brief summary:
DESIGN AGREED
=============
Candidate: <name>
Seam: <where>
Depth gained: <what moves behind the interface>
CONTEXT.md updated: yes | no
ADR offered: yes | no | n/a
Next step: use refactoring-code to apply
tools
Idiomatic shell development for POSIX sh, Bash, Zsh, Fish, hooks, CI shell steps, and scriptable CLI glue. Use when writing or changing `.sh`, `.bash`, `.zsh`, `.fish`, `.bats`, shell functions, shell pipelines, or command-runner recipes. Emphasizes portability, quoting, safe filesystem/process handling, non-TUI CLI tools, ShellCheck, shfmt, Bats, and ShellSpec. NOT for Python, TypeScript, Go, web code, or infrastructure operations.
tools
Use when planning, executing, checkpointing, finishing, or inspecting lightweight spec-driven work. Runs one task at a time using `.spec/` markdown files and the bundled `specctl` helper. NOT for broad product discovery beyond a short requirement interview.
testing
Author, inspect, troubleshoot, and review infrastructure across IaC, Kubernetes, cloud resources, containers, CI/CD, and Linux hosts. Use when changing Terraform/OpenTofu, Kubernetes, Helm, Kustomize, Dockerfiles, GitHub Actions, AWS, GCP, Cloud Run, BigQuery, IAM, logs, instances, or service health. NOT for deploy/apply/rollback workflows (see deploying-infra). NOT for shell scripts or generic command pipelines (see writing-shell).
development
Configure safe git workflow hygiene: pre-commit/pre-push hooks, Gitleaks secret scanning, .gitignore rules, local git config, and guardrails. Use when setting up git hooks, gitleaks/git leaks, staged pre-commit checks, pre-push validation, core.hooksPath, .gitignore, or git config best practices. NOT for creating commits (use committing-code), cleaning branches/worktrees (use cleanup-git), or creating worktrees (use using-git-worktrees).