agentleFS
kcsujeetkcsujeet/ilamy-calendar/.agents/skills/code-refactor-review/SKILL.md

code-refactor-review

Skill353 starsChanged 43 days agoMITView on GitHub

Reviews code changes for reuse, composition, codebase consistency, and slop. Use when asked to review PRs/diffs, check code reuse, composition, cleanliness, or whether code fits the codebase.

3 other projects use a version of this, 3 of them edited.

Adopted by

Most recently taken up by

  • Other versions3 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 3

    1. trycompai/crm★ 12k98% same
    2. jnsahaj/skills★ 10598% same
    3. nbbaier/agent-skills★ 15100% same

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

26 rules. 24 are common, 0 are distinctive, and 2 are very specific to this project.

  • 24

    Common

    Most of the 3 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Common:

    Use git diff for unstaged changes.

    line 13
  2. Common:

    Use git diff HEAD if there are staged changes.

    line 14
  3. Common:

    Search the codebase before judging new helpers, components, hooks, or patterns.

    line 17
  4. Common:

    Look for existing utilities, components, hooks, server actions, route patterns, copy patterns, and styling primitives before accepting …

    line 23
  5. Common:

    Prefer reusing the existing flow even if it needs a small extension.

    line 25
  6. Common:

    If the new code creates a shared helper, verify it has real reuse and is not just extracted private logic with a vague name.

    line 26
  7. Common:

    Avoid implementation details in names unless they are the actual product/API distinction.

    line 32
  8. Very specific:

    Use existing result/error/loading patterns.

    line 33
  9. Common:

    Avoid grab-bag modules that mix unrelated concerns like flags, API calls, transformation, UI state, logging, and scheduling.

    line 39
  10. Common:

    Avoid parameter sprawl. If a function needs many knobs, check whether the boundary is wrong.

    line 40
  11. Common:

    Prefer simple composition over chains of callbacks, wrappers, memoized helpers, and prop plumbing.

    line 41
  12. Common:

    Keep domain-specific logic close to its domain unless there is proven cross-domain reuse.

    line 43
  13. Common:

    Avoid redundant state and synchronization effects.

    line 60
  14. Common:

    Do not add memoization just to quiet performance anxiety.

    line 61
  15. Common:

    Prefer straightforward component boundaries over prop/callback gymnastics.

    line 62
  16. Common:

    Prefer deleting code over adding new structure.

    line 67
  17. Common:

    Prefer one clear function over several helper-y fragments unless extraction improves reuse or readability.

    line 68
  18. Common:

    Keep the fix proportional to the problem.

    line 69
  19. Common:

    Do not add architecture, docs, or comments unless they remove ambiguity for future readers.

    line 70
  20. Common:

    Start with a verdict:

    line 74
  21. Common:

    If the user asked for review only, do not edit files.

    line 87
  22. Common:

    Do not invent architecture.

    line 104
  23. Common:

    Search before claiming something is reusable or inconsistent.

    line 105
  24. Common:

    If a pattern is not present in the codebase, say so and recommend the smallest clean alternative.

    line 106
  25. Very specific:

    Prefer if statements over ternaries when suggesting code changes in v0.

    line 107
  26. Common:

    When in doubt, optimize for code that reads obvious from left to right.

    line 108

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Code Refactor Review

Review code changes the way Sahaj usually asks for review: go deep on reuse, composition, codebase consistency, and anything that reads like slop.

First Pass

  1. Inspect the full diff:
    • Use git diff for unstaged changes.
    • Use git diff HEAD if there are staged changes.
    • For a PR URL, inspect the changed files and understand the feature flow before reviewing details.
  2. Build the call stack / data flow when useful. Do not review isolated lines without understanding how the feature is wired.
  3. Search the codebase before judging new helpers, components, hooks, or patterns. Prefer nearby and sibling patterns over invented abstractions.

Review Lenses

1. Reuse Existing Code

  • Look for existing utilities, components, hooks, server actions, route patterns, copy patterns, and styling primitives before accepting newly written code.
  • Flag duplicated logic, copied helpers, or custom implementations of things the codebase already has.
  • Prefer reusing the existing flow even if it needs a small extension.
  • If the new code creates a shared helper, verify it has real reuse and is not just extracted private logic with a vague name.

2. Codebase Consistency

  • File placement should match the domain and neighboring features. Be suspicious of random top-level lib dumps.
  • Naming should match what the code actually does and follow sibling file/function names.
  • Avoid implementation details in names unless they are the actual product/API distinction.
  • Use existing result/error/loading patterns. Do not invent bespoke success/failure types when the codebase has a standard one.
  • Match existing copy and tone for user-facing text.

3. Composition and Boundaries

  • Functions should do one thing at the right level of abstraction.
  • Avoid grab-bag modules that mix unrelated concerns like flags, API calls, transformation, UI state, logging, and scheduling.
  • Avoid parameter sprawl. If a function needs many knobs, check whether the boundary is wrong.
  • Prefer simple composition over chains of callbacks, wrappers, memoized helpers, and prop plumbing.
  • When two backing entities are presented as one product concept, package them into one transport/view model across intermediate components. Black-box components should receive one unified prop/callback and should not care about distinctions like remote vs prebuilt; split back into core entities only at roots/adapters where persistence or payload formats require it.
  • Keep domain-specific logic close to its domain unless there is proven cross-domain reuse.

4. Slop Detection

Flag and, when asked, remove:

  • Comment slop: obvious comments, comments defending awkward code, long comments that should become clearer code, stale context in PR descriptions.
  • Helper slop: tiny wrappers that add no meaning, helper files created only to make one function look shorter, unnecessary indirection.
  • Type slop: exported one-off types, custom result shapes, annotations where inference is clearer, types that only paper over awkward code.
  • Memo/callback slop: useMemo / useCallback added without a measured or structural reason.
  • Effect slop: effects that mirror props/state, reset derived state, or handle events after the fact.
  • Compatibility cruft: bolted-on behavior that preserves accidental architecture instead of building the coherent end state.
  • Diff churn: unrelated renames, formatting, comments, or wrappers that make the PR larger without improving the design.

5. React / Next.js Quality

  • Apply “You Might Not Need an Effect”: derive values during render, move event-caused work into event handlers, and reset state with keys when appropriate.
  • Avoid redundant state and synchronization effects.
  • Do not add memoization just to quiet performance anxiety. Memoization should solve a real render identity or expensive computation issue.
  • Prefer straightforward component boundaries over prop/callback gymnastics.
  • For server/data code, avoid unnecessary waterfalls and run independent work concurrently when the codebase has a pattern for it.

6. Minimality

  • Prefer deleting code over adding new structure.
  • Prefer one clear function over several helper-y fragments unless extraction improves reuse or readability.
  • Keep the fix proportional to the problem.
  • Do not add architecture, docs, or comments unless they remove ambiguity for future readers.

Output Format

Start with a verdict:

  • clean — no meaningful concerns.
  • mostly clean — minor cleanup only.
  • needs cleanup — important reuse/composition/consistency issues.

Then list findings by priority. For each finding include:

  1. File path and relevant symbol/area.
  2. What reads as slop or inconsistency.
  3. The existing pattern or code that should be reused, if found.
  4. The minimal recommended fix.

If the user asked for review only, do not edit files. If the user asked to fix it, make the changes directly and summarize what changed.

Red Flags

  • “Can we reuse existing code?” was not answered with a search.
  • New top-level helpers with vague names like utils, helpers, shared, or implementation-specific names.
  • A function whose name hides important side effects.
  • A directory containing only index.ts without a reason.
  • Re-exporting something that is already exported elsewhere.
  • New custom primitives where the product already has a component or pattern.
  • Large comments explaining why awkward props or flags exist.
  • Multiple new types just to support one local function.
  • New callback/memo/effect code that disappears if state ownership is simplified.

Rules

  • Be direct and concise. Avoid extra explanatory fluff.
  • Do not invent architecture. Ground claims in codebase patterns.
  • Search before claiming something is reusable or inconsistent.
  • If a pattern is not present in the codebase, say so and recommend the smallest clean alternative.
  • Prefer if statements over ternaries when suggesting code changes in v0.
  • When in doubt, optimize for code that reads obvious from left to right.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.