AGENT SKILL

untangling-codebases

Refactors a whole codebase in one pass so each change lands in one place: catalogs hidden links, needless links, surplus code, and special cases, redesigns to remove their shared causes, and repeats until nothing worth fixing is left. Use when the user says "untangle this codebase", or when asked to refactor a whole codebase so changes land in one place. Never infer from a bug fix or feature request. Not for one new requirement; use redesigning-from-first-principles.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 2
Forks
0

01 前言 Front Matter

name
untangling-codebases
description
Refactors a whole codebase in one pass so each change lands in one place: catalogs hidden links, needless links, surplus code, and special cases, redesigns to remove their shared causes, and repeats until nothing worth fixing is left. Use when the user says "untangle this codebase", or when asked to refactor a whole codebase so changes land in one place. Never infer from a bug fix or feature request. Not for one new requirement; use redesigning-from-first-principles.
argument-hint
[<area or concern to focus on>]

02 资源文件 2

03 SKILL.md 正文

Untangle a Codebase

Refactor the whole codebase, or the area the user names, and finish. Treat it as a goal, not a list of suggestions. Behavior stays the same.

The aim is code where an agent reads little per change, a change lands in one place, and a break shows up instead of hiding.

The test for every finding: should these pieces change together? Pieces that must change together but look apart are a hidden link. Pieces that look together but need not change together are a needless link.

  1. Ask about the extras. Offer two optional passes and wait for the answer, then do only the chosen ones:
    • Comments: delete comments that restate the code.
    • Tests: delete tests that cannot catch a real bug, and rewrite tests coupled to internals to test behavior.
  2. List every problem before changing anything. Read the code and git history (files that change in the same commits are linked). Record each problem with path:line:
    • Hidden links: copied logic or constants, state read from globals or files written elsewhere, one feature split across folders by layer, call-order rules nothing enforces.
    • Needless links: callers that reach into internals, stable code importing volatile code, general functions with parameters for one workflow, shallow modules whose interface is as big as their body.
    • Surplus: pass-through wrappers, config or extension points with one use, dead code.
    • Special cases: a branch for one value, a parameter for one caller, a swallowed exception, a retry or sleep, a skipped test. Read each as a requirement the design is missing.
  3. Redesign from the causes. Group problems that share a cause and find the one change that removes the group. Never patch special cases one at a time. Write a decision log: each fix, then the problems it removes, as in the example.
  4. Fix everything on the list. Apply the fixes in the log, then delete the special cases the redesign made unnecessary. Run the project's checks after each fix and keep them passing. For Comments, also delete comments that worked around a problem the redesign removed; keep comments about facts outside the code. Do Tests last.
  5. Check and repeat. Start subagents with fresh context, never a fork of this conversation, each looking for one kind of problem from step 2 in the changed code. Fix what they find and check again. Stop when a new pass finds nothing worth fixing.

Done when few special cases remain, a typical change touches one place, imports point from volatile code to stable code, and the full test suite passes with behavior unchanged.

Tips

  • Map before reading: script a dependency graph from imports, and have fresh-context subagents summarize large areas.
  • Start where one fix removes the most problems.
  • Read a skeleton first: signatures and types without bodies show the shape faster than the full code.

Report

Reply with the decision log, what each pass found, the checks you ran with their results, and any problem you left with why.

04 同仓库更多 Skills

bostonaholic
bostonaholic/skills

writing-system-prompts

Writes and reviews system prompts for AI tools, agents, chatbots, and LLM products using a fixed section order and a quality checklist. Use when the user says "write a system prompt", or when drafting a system prompt or auditing one for missing stop criteria, tool rules, constraints, or examples. Not for compressing an existing prompt; use improving-prompts.

★ 2
bostonaholic
bostonaholic/skills

writing-prose

Writes and edits prose for people in a plain, conversational, short house style with no em dashes. Use when the user says "write this up", or when drafting or revising documentation, READMEs, explanations, blog posts, or other human-facing prose. Not for prompts written for agents; use writing-system-prompts or composing-agent-prompts.

★ 2
bostonaholic
bostonaholic/skills

writing-acceptance-criteria

Writes or rewrites acceptance criteria until each is provable: one observable outcome with a named check that can fail. Use when the user says "write acceptance criteria", or asks to write, rewrite, or tighten acceptance criteria or a definition of done. Not for proving work meets them; use proving-claims.

★ 2
bostonaholic
bostonaholic/skills

summarizing-shipped-work

Summarizes the user's merged GitHub PRs for a timeframe into a grouped, linked shipped-work report with highlights, and offers to update a brag document. Use when the user says "what shipped?", or when asked what the user shipped (this week, last month, a quarter, since a date), for a status update, or to update a brag doc.

★ 2
bostonaholic
bostonaholic/skills

running-retros

Mines a session transcript, past agent sessions, or named sources such as PR review comments for durable learnings, then proposes approval-gated edits to skills, AGENTS.md, or docs and tracker issues. Use when the user says "retro", or when the user explicitly asks for a retrospective. Never infer from session end or friction.

★ 2
bostonaholic
bostonaholic/skills

learning-from-mistakes

Codifies the latest correction or mistake in the conversation as a short imperative rule in the project or global CLAUDE.md or AGENTS.md, after the user approves it. Use when the user says "learn from this mistake", or when the user asks to learn from a mistake, remember a lesson for next time, add a rule to CLAUDE.md, or not repeat a behavior. Not for a whole session; use running-retros.

★ 2