agent-instructions
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what does not, structure, and…
Use when improving the structure of code without changing its behavior. Covers safe refactoring sequences, characterization tests, and knowing when to stop.
$ npx -y skills add nimadorostkar/Claude-Skills-collection --skill refactoring --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/refactoringContext preview
The summary Claude sees to decide when to auto-load this skill.
Use when improving the structure of code without changing its behavior. Covers safe refactoring sequences, characterization tests, and knowing when to stop.
name: refactoring description: Use when improving the structure of code without changing its behavior. Covers safe refactoring sequences, characterization tests, and knowing when to stop. metadata: category: development version: 1.0.0 tags: [refactoring, code-quality, technical-debt, testing]
Change the structure of code while provably preserving behavior. The defining constraint is that behavior does not change — if it does, it is a rewrite, and it needs different scrutiny.
1. **Justify it** — Name the concrete cost the current structure imposes. "It's ugly" is not a cost. "Every new payment method requires editing five files" is. 2. **Pin the behavior** — If tests do not cover the code, write characterization tests first: call the code, record what it actually does, assert that. Bugs included. 3. **Refactor in small steps** — One mechanical transformation per commit. Run the tests after each. 4. **Do not mix in behavior changes** — A refactoring commit and a feature commit must be separate. Reviewers cannot verify both at once. 5. **Stop when the motivating change is easy** — Refactoring is preparation, not a destination.
**Breaking a dependency to make code testable:**
# Before: untestable — reaches out to the network and the clock.
def send_expiry_warnings():
for user in db.query("SELECT * FROM users WHERE expires_at < now() + interval '7 days'"):
smtp.send(user.email, render("expiry_warning", user=user))
# After: dependencies are seams. Behavior is unchanged.
def find_expiring_users(db, now, window=timedelta(days=7)):
return db.users_expiring_before(now + window)
def send_expiry_warnings(db, mailer, now):
for user in find_expiring_users(db, now):
mailer.send(user.email, render("expiry_warning", user=user))The test can now supply a fake `db`, a fake `mailer`, and a fixed `now` — without a network, a database, or a sleep.
A curated library of 137 production-grade skills for Claude and other AI coding agents. Every skill follows one structure, speaks with one voice, and earns its place by changing what the agent does.
Repo: nimadorostkar/Claude-Skills-collection
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what does not, structure, and…
Use when an agent needs state that survives a session or a context compaction. Covers what to persist, file-based memory, structuring notes for retrieval, and…
Use when automating agent behavior with lifecycle hooks. Covers hook events, deterministic enforcement of rules the model should not be trusted to remember,…
Use when packaging skills, commands, hooks, and MCP servers into a distributable plugin. Covers manifest structure, bundling, versioning, testing, and…
Use when writing a new skill for an AI agent. Covers scoping, description writing for reliable triggering, progressive disclosure, and the difference between a…
Use when reviewing or improving an existing agent skill. Covers triggering accuracy, content quality, redundancy with the base model, and measuring whether the…