Agent skill

Deep Refactor Audit

by AlmanacCode in AlmanacCode/codealmanac

A skill your agent uses when a user asks for a major architecture/refactor audit, codebase smell investigation, boundary critique, feature simplification review, vibe-coded or AI-generated code…

Apache-2.0Auto-check passedDevelopment

Install Deep Refactor Audit

skills CLI
$ npx skills add AlmanacCode/codealmanac --skill deep-refactor-audit -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install AlmanacCode/codealmanac deep-refactor-audit --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/AlmanacCode/codealmanac.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/deep-refactor-audit .claude/skills/deep-refactor-audit && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
deep-refactor-audit
GitHub stars
997
Token cost
~3.5k tokens
SKILL.md length
1,118 words
Files
2
Skills in repo
2
Repo updated
First seen
Licence
Apache-2.0

At a glance

A skill your agent uses when a user asks for a major architecture/refactor audit, codebase smell investigation, boundary critique, feature simplification review, vibe-coded or AI-generated code…

  • A user asks for a major architecture/refactor audit
  • SKILL.md covers Overview, Core Stance, Audit Boundary and Start By Setting A Goal, plus 11 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Codebase smell investigation

What it does

Deep Refactor Audit is an agent skill from AlmanacCode/codealmanac. Use when a user asks for a major architecture/refactor audit, codebase smell investigation, boundary critique, feature simplification review, vibe-coded or AI-generated code cleanup assessment, hand-rolled library review, or no-code report on how a codebase should be reshaped.

Its SKILL.md is about 3.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `agents/openai.yaml`).

It sits in Development, covering Refactoring. It works with TypeScript. The repository describes itself as: A codebase wiki for AI coding agents. Captures what the code can't say: decisions, flows, invariants, gotchas. The licence is Apache-2.0.

When your agent uses it

  • A user asks for a major architecture/refactor audit
  • Codebase smell investigation
  • Boundary critique
  • Feature simplification review

Example prompts

  • “/deep-refactor-audit”

What it can do on your machine

Read from SKILL.md and the folder at commit 0f15350. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Deep Refactor Audit loads about 3.5k tokens when it runs. Until then it costs about 74 tokens; SKILL.md has 1,118 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~74
When it runs · the whole SKILL.md, loaded when a task matches
~3.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from AlmanacCode/codealmanac at commit 0f15350, republished under its Apache-2.0 licence (© AlmanacCode). 1,118 words, ~3,470 tokens.

Download SKILL.mdSave it as .claude/skills/deep-refactor-audit/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
deep-refactor-audit
description
Use when a user asks for a major architecture/refactor audit, codebase smell investigation, boundary critique, feature simplification review, vibe-coded or AI-generated code cleanup assessment, hand-rolled library review, or no-code report on how a codebase should be reshaped.

Deep Refactor Audit

Overview

This is a no-code architecture audit for aggressively rethinking a codebase. The job is to ask why the codebase is shaped this way, whether that shape still deserves to exist, and what a strong principal engineer would change before allowing the system to keep growing.

AI-generated code often accumulates accidental architecture: features nobody asked to keep, abstractions created for one use case, hand-rolled versions of standard libraries, over-flexible configuration, compatibility paths with no owner, and names that hide what the code actually does. Treat those as suspect until they earn their place.

Core Stance

Because this audit does not modify production code, take intellectual risks. Be creative, skeptical, and specific. Question architecture, naming, feature value, user behavior, dependencies, and whether whole subsystems should exist.

Do not be polite at the expense of usefulness. The valuable output is not "some code smells exist." The valuable output is a clear opinion about what should be preserved, simplified, deleted, or redesigned.

Audit Boundary

Do not edit implementation files during this audit. You may create notes, diagrams, reports, and plans under docs/.

This restriction is not meant to make the audit timid. It exists so the diagnosis can be bolder than an implementation task.

Start By Setting A Goal

Before the deep dive, set an explicit audit goal. If the environment has a goal mechanism, use it. Otherwise write the goal at the top of the audit worklog.

Use this shape:

text
Goal:
Critically audit <scope> to determine which architecture, features, boundaries, names, abstractions, dependencies, and workflows should be preserved, simplified, removed, or redesigned.

Core questions:
- Why does this exist?
- Is it still needed?
- Is this the simplest shape that can support the product?
- Did this complexity come from real constraints or accidental accumulation?
- Is this hand-rolled code justified, or should it use a standard library/framework capability?
- What would the architecture look like if we designed it cleanly today?

Non-goals:
- Do not modify production code.
- Do not produce a shallow smell list.
- Do not assume the current architecture is justified.
- Do not recommend patterns without explaining concrete movement in the codebase.

Success criteria:
- Current architecture is mapped.
- Major boundaries are judged.
- Questionable features are called out.
- Hand-rolled machinery is compared against existing libraries or framework capabilities.
- Accidental complexity is separated from legitimate complexity.
- Prior art, named patterns, and mature repositories are researched where useful.
- A target architecture and refactor roadmap are written.

Create Audit Artifacts

Create a dated folder:

text
docs/refactor-audit-YYYY-MM-DD/
  README.md
  worklog.md
  source-map.md
  smells.md
  feature-questions.md
  hand-rolled-inventory.md
  research-notes.md
  subagent-briefs.md
  reports/
  target-architecture.md
  refactor-roadmap.md

Use fewer files for a small repository, but always keep a running worklog. Write notes throughout the audit, not only at the end. The worklog must let another agent resume after compaction without losing the important insights.

Read With Suspicion

For every subsystem, ask:

  • Why does this exist?
  • Who benefits from this behavior?
  • Is this feature actually wanted, or did it survive because nobody deleted it?
  • Is this complexity paying rent?
  • Would a user notice if this feature disappeared?
  • Would a maintainer be relieved if this feature disappeared?
  • Is this a general mechanism, or a one-off that got promoted into architecture?
  • Does the name describe what the code really does?
  • Are decisions separated from mechanisms?
  • Are framework, provider, or transport details leaking into core logic?
  • Is this hand-rolled because it needed to be, or because the original author did not look for a library?
  • Would the second or third similar feature fit cleanly, or require teardown?
  • If we rebuilt this today, would we choose this shape again?

Classify findings as:

text
Keep:
The complexity is justified by product value, external constraints, safety, compatibility, performance, or repeated use.

Simplify:
The feature or boundary is useful, but the implementation is more complex than the value requires.

Delete candidate:
The feature, path, abstraction, dependency, parser, compatibility layer, or workflow appears to cost more than it is worth.

Replace with library:
The code hand-rolls a solved problem without a strong reason.

Redesign:
The concept is important, but the current boundary is wrong.

Unknown:
There may be a real reason, but the audit did not find enough evidence.

Look For AI-Generated Accumulation

AI-written code often has specific failure modes. Look for:

  • Features added because they were easy, not because they were needed
  • Options, modes, and flags with no clear user story
  • Generic abstractions with only one real implementation
  • "Extensible" systems where extension was never exercised
  • Compatibility shims that outlived the migration
  • Helpers that hide product decisions
  • Retry, fallback, and recovery paths nobody can explain
  • Multiple ways to do the same thing
  • Long files that read like a transcript of incremental requests
  • Names that sound architectural but hide narrow behavior
  • Defensive code around states the product should not allow
  • Config knobs that encode product policy instead of mechanics
  • Test fixtures that preserve old architecture because changing them was annoying
  • Custom parsers, serializers, schedulers, state machines, or clients for problems with mature off-the-shelf solutions

Be willing to say: this whole feature may not deserve to exist.

Audit Hand-Rolled Machinery

Treat hand-rolled infrastructure as a first-class audit target. Sometimes it is correct. Often it is accidental.

Inventory custom implementations of:

  • Markdown, YAML, JSON, TOML, CSV, HTML, XML, or URL parsing
  • Date/time, duration, timezone, or recurrence handling
  • Glob, path, routing, or pattern matching
  • CLI parsing, config loading, logging, formatting, prompts, or progress output
  • HTTP clients, retries, pagination, rate limiting, auth, or SDK wrappers
  • Job queues, schedulers, locks, leases, idempotency, or state transitions
  • Caches, stores, migrations, repositories, and transaction helpers
  • Validation, schema parsing, typed results, error formatting, and redaction
  • React state, forms, tables, virtualization, drag/drop, rich text, or data fetching

For each one, ask:

text
What is hand-rolled?
What standard library, framework feature, or popular package already solves this?
What special constraints might justify custom code?
What bugs or maintenance costs does the custom version create?
What would be deleted if we adopted the existing solution?
What would become harder if we adopted it?
Recommendation: keep custom / replace / wrap library behind a seam / research further.

Do not blindly demand libraries. A small owned parser for a tiny syntax may be better than a heavy dependency. A security-sensitive or performance-sensitive boundary may justify custom code. The audit should force the question and document the answer.

Show full SKILL.md (410 more words)Show less

Research Prior Art And Name Patterns

When the code is solving a known problem, research how mature systems solve it. Use web search, official docs, respected engineering writing, and open-source repositories when useful.

Name patterns explicitly. Patterns give vocabulary to the critique.

Use patterns as tools, not decorations. For each pattern, explain:

text
Pattern:
Where it applies:
What would move:
What boundary would exist:
What gets simpler:
What gets more complex:
Why this is or is not worth it here:

Useful patterns to consider:

  • Ports and adapters
  • Hexagonal architecture
  • Clean architecture
  • Functional core, imperative shell
  • Command/query separation
  • Command pattern
  • Strategy pattern
  • Adapter pattern
  • Facade pattern
  • Repository pattern
  • Unit of work
  • Domain events
  • Event sourcing
  • Outbox pattern
  • Pipeline architecture
  • State machine
  • Actor model
  • Plugin registry
  • Dependency inversion
  • Layered architecture
  • Vertical slice architecture
  • Feature folders
  • Modular monolith
  • Anti-corruption layer
  • Workflow orchestration
  • Durable jobs
  • Idempotency boundaries

Also inspect real repositories. If the codebase has a CLI, inspect respected CLI projects. If it has background jobs, inspect job queue systems. If it has multiple providers, inspect SDKs or tools with provider adapters. If it has a frontend, inspect mature apps using the same framework.

Do not copy blindly. Borrow shape.

Challenge Features, Not Just Code

A deep refactor audit is allowed to question product surface area.

For each expensive feature, ask:

text
Feature:
What user behavior requires this?
What code complexity does it create?
What other features does it distort?
What would break if it disappeared?
Could a simpler product behavior replace it?
Should we keep, simplify, hide, or remove it?

Examples:

text
A reporting system supports six export formats, but users only need CSV.
Recommendation: delete or defer the unused formats. Keep the export boundary small until usage proves otherwise.
text
A plugin system exists before there are external plugins.
Recommendation: keep a clean internal interface, but remove plugin discovery, lifecycle hooks, and registry machinery until a second real plugin exists.
text
A settings page exposes every internal knob.
Recommendation: separate user preferences from operator/configuration concerns. Remove settings that users cannot reason about.

Use Subagents Aggressively

When available, use subagents for independent critique. Do not ask them to validate your opinion. Ask them to find the strongest objections.

Useful subagent roles:

text
Boundary critic:
Find modules with mixed responsibilities, misleading names, hidden policy, and bad dependency direction.

Feature skeptic:
Find features, flags, modes, compatibility paths, and abstractions that may not deserve to exist.

Hand-rolled machinery critic:
Find custom implementations of solved problems. Compare them against standard libraries, framework features, and popular packages.

Pattern researcher:
Research named architecture patterns and mature open-source examples relevant to one subsystem.

Deletion advocate:
Argue what should be removed entirely. Identify product simplifications that would collapse code complexity.

Target architect:
Propose a cleaner architecture from first principles, ignoring migration cost at first.

Migration realist:
Take the target architecture and identify sequencing, risks, tests, and rollback points.

Save subagent outputs under reports/.

Produce A Strong Diagnosis

Each major finding should use this structure:

text
Finding:
Evidence:
Why it exists today:
Why that reason may no longer be good enough:
Architectural cost:
User/product value:
Hand-rolled or dependency concern:
Recommendation:
Pattern or prior art:
Risk:
Confidence:
Files inspected:

Be direct. A useful audit may say:

text
This module should not exist.
This feature is distorting the architecture.
This abstraction is premature.
This boundary is too weak.
This name is lying.
This subsystem should become three modules.
This workflow should be deleted unless there is evidence users need it.
This parser should be replaced by a library unless the custom grammar is a product requirement.

Target Architecture

Do not stop at criticism. Propose the shape the codebase should move toward.

Include:

  • New boundaries
  • Renamed concepts
  • Deleted or collapsed concepts
  • Hand-rolled machinery to replace, keep, or isolate
  • Patterns worth adopting
  • Patterns explicitly rejected
  • How the main flows would read after the refactor
  • Which features become easier
  • Which features become intentionally unsupported

Use lightweight pseudocode when helpful:

ts
const request = commands.parse(argv);
const result = await operations.run(request);
output.render(result, request.outputMode);

Explain why that shape is cleaner.

Refactor Roadmap

The roadmap should separate courage from chaos.

Group work into:

text
Phase 0: Delete, hide, or freeze questionable surface area
Phase 1: Replace unjustified hand-rolled machinery or isolate it behind honest seams
Phase 2: Rename concepts so the architecture can be discussed honestly
Phase 3: Move decisions out of mechanisms
Phase 4: Introduce the right architectural seams
Phase 5: Collapse or replace obsolete workflows
Phase 6: Harden tests around the new shape

For each phase, include:

text
Goal:
Changes:
Why first:
Risk:
Verification:

Final Report

The final report should include:

  • Executive summary
  • Current architecture map
  • Strongest architectural objections
  • Feature deletion or simplification candidates
  • Hand-rolled machinery inventory and recommendations
  • Legitimate complexity worth preserving
  • Accidental complexity likely caused by incremental or AI-generated work
  • Prior art, mature repositories, and named patterns considered
  • Target architecture
  • Refactor roadmap
  • Open questions for the user
  • Reports and notes written

The tone should be serious, opinionated, and evidence-based. This is not a polite lint pass. This is the moment to ask whether the codebase deserves its current shape.

© AlmanacCode, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in .agents/skills/deep-refactor-audit of AlmanacCode/codealmanac.

  • SKILL.md
  • agents/openai.yaml

Open the folder on GitHubat commit 0f15350

Compare with similar skills

Deep Refactor Audit next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Deep Refactor Audit compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Deep Refactor Audit this skillAlmanacCode/codealmanac997—~3.5kAutomated safety check: PassApache-2.0
Svelte5 Best PracticesSikandarJODD/cnblocks4301 repos~810Automated safety check: PassMIT
Dinero Best Practicesdinerojs/dinero.js6.8k—~756Automated safety check: PassMIT
Code Guidelinesgetsentry/sentry-react-native1.8k—~3.2kAutomated safety check: PassMIT
AST Visitor Pattern for Unionsprisma/orm48k—~830Automated safety check: PassApache-2.0
ast-grep Codemod Referencewarp-drive-data/warp-drive3.2k—~2.6kAutomated safety check: PassMIT

Similar skills

  • Svelte5 Best Practices

    SikandarJODD/cnblocks

    Svelte 5 runes, snippets, SvelteKit patterns, and modern best practices for TypeScript and component development.

    430 GitHub starsUsed in 1 repo~810 tokens
    DevelopmentAuto-check passed
  • Dinero Best Practices

    dinerojs/dinero.js

    Core best practices for the Dinero.js money library. An agent skill from dinerojs/dinero.js.

    6.8k GitHub stars~756 tokensUpdated 2 days ago
    DevelopmentAuto-check passed
  • Code Guidelines

    getsentry/sentry-react-native

    Official

    Enforce Sentry React Native SDK code guidelines for implementation, refactoring, and review.

    1.8k GitHub stars~3.2k tokensUpdated today
    DevelopmentAuto-check passed
  • Official

    Replaces a plain TypeScript union plus switch statements with frozen subclasses and a visitor interface when several places dispatch on the same variants.

    48k GitHub stars~830 tokensUpdated today
    DevelopmentAuto-check passed
  • ast-grep Codemod Reference

    warp-drive-data/warp-drive

    Reference for writing and debugging TypeScript and JavaScript codemods with @ast-grep/napi: parsing, node queries, meta-variables, rule objects and editing.

    3.2k GitHub stars~2.6k tokensUpdated today
    DevelopmentAuto-check passed
  • Dep Refs

    zai-org/ZCode

    A skill your agent uses when needs to inspect TypeScript export references in the z-code workspace, list exports from a file, verify whether an export is unused before deletion, investigate who…

    7.5k GitHub stars~552 tokensUpdated 8 days ago
    DevelopmentAuto-check passed

More from AlmanacCode/codealmanac

  • Cleanslate

    AlmanacCode/codealmanac

    A skill your agent uses when the user asks to run or prepare the Almanac clean-slate workflow, uninstall all local codealmanac/Almanac CLI artifacts, or reset a machine to first-time Almanac install…

    997 GitHub stars~877 tokensUpdated 2 mo ago
    Auto-check passed

Works with

Questions about Deep Refactor Audit

What does Deep Refactor Audit do?

A skill your agent uses when a user asks for a major architecture/refactor audit, codebase smell investigation, boundary critique, feature simplification review, vibe-coded or AI-generated code…. Deep Refactor Audit is an agent skill from AlmanacCode/codealmanac. Use when a user asks for a major architecture/refactor audit, codebase smell investigation, boundary critique, feature simplification review, vibe-coded or AI-generated code cleanup assessment, hand-rolled library review, or no-code report on how a codebase should be reshaped.

When should I use Deep Refactor Audit?

Deep Refactor Audit fits situations like: A user asks for a major architecture/refactor audit; codebase smell investigation; boundary critique; feature simplification review.

How do I install Deep Refactor Audit in Claude Code?

Run `npx skills add AlmanacCode/codealmanac --skill deep-refactor-audit -a claude-code`. Or copy the skill folder (.agents/skills/deep-refactor-audit in AlmanacCode/codealmanac) into .claude/skills/deep-refactor-audit in your project. Claude Code loads it when a task matches its description.

How do I install Deep Refactor Audit in Codex?

Run `npx skills add AlmanacCode/codealmanac --skill deep-refactor-audit -a codex`. Or copy the skill folder (.agents/skills/deep-refactor-audit in AlmanacCode/codealmanac) into .agents/skills/deep-refactor-audit in your project. Codex loads it when a task matches its description.

Can I use Deep Refactor Audit in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add AlmanacCode/codealmanac --skill deep-refactor-audit -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/deep-refactor-audit, .gemini/skills/deep-refactor-audit, .github/skills/deep-refactor-audit and .opencode/skills/deep-refactor-audit in your project.

What does Deep Refactor Audit need to run?

SKILL.md names no scripts, command-line tools or credentials: Deep Refactor Audit is instructions for the agent only.

Does Deep Refactor Audit access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Deep Refactor Audit safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Deep Refactor Audit use?

Deep Refactor Audit is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Deep Refactor Audit use?

About 3.5k tokens (SKILL.md is roughly 14k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Deep Refactor Audit?

Skills that share tags, products or a category with Deep Refactor Audit: Svelte5 Best Practices (SikandarJODD/cnblocks, 430 stars), Dinero Best Practices (dinerojs/dinero.js, 6.8k stars), Code Guidelines (getsentry/sentry-react-native, 1.8k stars) and AST Visitor Pattern for Unions (prisma/orm, 48k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Deep Refactor Audit?

AlmanacCode (a GitHub organization) maintains it in AlmanacCode/codealmanac, which has 997 GitHub stars. The repository holds 2 skills in this directory. The repository was last updated on July 25, 2026.

Source: AlmanacCode/codealmanac on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.