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.5 | $0.00007 | $0.00411 |
| Sonnet 5.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 1mo 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.
- 1mo 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 24d ago), licensed MIT. It adds 18 tokens to every session and 1,028 once invoked, about $0.0001 per session on Opus 5.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
customer-journey-map
Construye un mapa de recorrido del cliente para un producto, servicio o experiencia. Úsalo cuando se te pida mapear un recorrido del cliente, crear un viaje del usuario, documentar puntos de contacto y puntos de fricción, o diseñar un mapa de experiencia. Produce un mapa de recorrido completo con etapas, puntos de…
user-story-writer
Escribir historias de usuario bien estructuradas con criterios de aceptación y casos extremos. Úsalo cuando te pidan escribir historias de usuario, crear tickets a partir de un resumen de características, convertir un PRD en historias o redactar criterios de aceptación. Produce historias listas para estimar en formato…
feature-prioritisation
Aplica marcos de priorización (RICE, MoSCoW, Kano, ICE, Opportunity Scoring) para clasificar características e items del backlog. Úsalo cuando se te pida priorizar características, clasificar un backlog, decidir qué construir a continuación, o evaluar compensaciones entre ideas competidoras. Produce una lista de…
morning-intelligence
Interviews you across 15 questions to capture your role, topics, sources, exclusions, and format preferences, then writes a master prompt you can paste into a scheduled task or Claude Code Routine. Use when you want to set up a personalised daily news brief, build a reusable morning news prompt, or create an automated…
data-analysis-standard
Estructura un análisis de datos de producto, análisis profundo de métricas, análisis de embudo o estudio de cohortes. Úsalo cuando te pidan analizar métricas de producto, investigar una caída en conversión, explicar un cambio de datos a stakeholders o encontrar la causa raíz de un movimiento de métrica. Produce un…
technical-spec-template
Crea documentos de especificación técnica estructurados que conectan requisitos de producto con implementación de ingeniería. Úsalo cuando escribas una especificación técnica, especificación de ingeniería, documento de diseño de sistema o especificación de API. Produce una especificación completa con declaración del…