Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add varunk130/ai-workflow-playbooks --skill safe-refactoringgit clone --depth 1 https://github.com/varunk130/ai-workflow-playbooksWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/varunk130/ai-workflow-playbooks/safe-refactoring)<a href="https://agentmods.dev/skills/varunk130/ai-workflow-playbooks/safe-refactoring"><img src="https://agentmods.dev/badge/skills/varunk130/ai-workflow-playbooks/safe-refactoring/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/varunk130/ai-workflow-playbooks/safe-refactoring"><img src="https://agentmods.dev/badge/skills/varunk130/ai-workflow-playbooks/safe-refactoring.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00018 | $0.01028 |
| Opus 5 | $0.00009 | $0.00514 |
| Sonnet 5 | $0.00004 | $0.00206 |
| Haiku 4.5 | $0.00002 | $0.00103 |
Grade A, and why
safe-refactoring scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 85 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Safe Refactoring
What This Skill Enables
Agents with this skill can improve code structure -- readability, modularity, performance -- while guaranteeing that external behavior stays identical. Without it, agents tend to rewrite large sections at once, introduce subtle regressions, and produce diffs that are impossible for humans to review confidently. Safe refactoring turns a risky "big bang" rewrite into a chain of small, provably correct transformations.
Core Competencies
1. Decide Whether to Refactor at All
Not every piece of ugly code needs attention right now. Before touching anything, answer these questions:
| Question | If "No", stop here |
|---|---|
| Is this code on the path of the current task? | Do not refactor drive-by style. |
| Do passing tests already cover the behavior? | Write tests first (see competency 2). |
| Is the improvement worth the review cost? | A rename across 200 files is noisy for little gain. |
| Is there a deadline within hours? | Ship first, refactor in a follow-up branch. |
Refactoring that is not motivated by a concrete upcoming change is speculative. Avoid it.
2. Lock Behavior with Tests Before Changing Structure
The "lock then change" pattern is non-negotiable:
Step 1 -- Write or confirm tests that cover the code you are about to move.
Step 2 -- Run the full relevant test suite. It must pass.
Step 3 -- Perform ONE refactoring move (see competency 3).
Step 4 -- Run the suite again. It must still pass.
Step 5 -- Commit with a single-purpose message.
Step 6 -- Repeat from Step 3 for the next move.
If no tests exist and writing them is impractical, add at minimum a characterization test: call the function with known inputs and assert on the current outputs, even if those outputs look wrong. The point is to detect change, not to validate correctness.
3. Use Named Refactoring Moves
Each commit should contain exactly one kind of transformation. Mixing moves makes regressions hard to bisect.
| Move | When to Use | Key Risk |
|---|---|---|
| Extract Function | A block inside a function has a clear name and purpose. | Getting the parameter list wrong; forgetting closures. |
| Inline Function | A wrapper adds no clarity and just indirects. | Callers may depend on the wrapper's name in tests or logs. |
| Rename | A name is misleading or does not match domain language. | Must update every reference, including strings and config. |
| Move to Module | A function lives in the wrong file or layer. | Import paths change; circular dependencies may surface. |
| Simplify Conditional | Nested if/else can be replaced with guard clauses or a lookup table. | Subtle short-circuit logic may be intentional. |
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 8d ago First seen · 85 lines · 18 tokens per session scan A d1a2f7d19876
safe-refactoring is a skill published in the GitHub repository varunk130/ai-workflow-playbooks (2 stars, last pushed 1mo ago), licensed MIT. It adds 18 tokens to every session and 1,028 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
prd-taskmaster
Zero-config goal-to-tasks engine (the Atlas engine). Takes any goal (software, pentest, business, learning), runs adaptive discovery via brainstorming, generates a validated spec, parses into TaskMaster tasks, and hands off to execution. Use when user says "PRD", "product requirements", "I want to build", invokes…
generate
Phase 2 of the prd-taskmaster pipeline: spec generation and task parsing. Loads a template (comprehensive|minimal), fills it with DISCOVER-phase constraints and answers, validates the spec (placeholdersfound, grade thresholds), parses the PRD into tasks via task-master, runs TaskMaster's native complexity analysis…
discover
Phase 1 of the prd-taskmaster pipeline: brainstorm-driven discovery. Delegates to superpowers:brainstorming in Interactive Mode (one adaptive question at a time), or self-brainstorms in Autonomous Mode when no user is present. Intercepts before the brainstorming chain hands off to writing-plans — this skill owns the…
ai-shaped-readiness-advisor
Assess whether your product work is AI-first or AI-shaped. Use when evaluating AI maturity and choosing the next team capability to build.
agent-orchestration-advisor
Design multi-agent AI workflows with clear boundaries, handoffs, and monitoring. Use when a complex PM task should run as parallel specialized agents instead of one linear process.
company-intel
Research a company, industry, or competitor set using web search and seven analytical lenses. Use when you need structured intel that feeds downstream PM skills.