refactor-seguro

refactor-seguro is a command for Claude Code from luanpdd/kit-mcp. It costs 49 tokens per session (3,505 once invoked), scanned A, original, MIT.

A guided refactoring command that checks code structure and existing behavior before carrying out a code change. Refactoring means changing code organization without intending to change what it does.

In plain words
What is it for?
Use it for full safety-checked refactors, small additions around old code, simple mechanical extractions, or documented overrides when the normal checks are intentionally bypassed.
Why use it?
It reduces the risk of breaking legacy code by finding safe change points, recording current behavior in tests, and applying a safety review before the refactor.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: names the AskUserQuestion tool; positional $N argument.

Good fit Use it for full safety-checked refactors, small additions around old code, simple mechanical extractions, or documented overrides when the normal checks are intentionally bypassed.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/luanpdd/kit-mcp/refactor-seguro
Install

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.

Clone the repo
git clone --depth 1 https://github.com/luanpdd/kit-mcp

Made for: Claude Code.

Wrote 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.

agentmods badge for refactor-seguro

README.md
[![agentmods](https://agentmods.dev/badge/commands/luanpdd/kit-mcp/refactor-seguro.svg)](https://agentmods.dev/commands/luanpdd/kit-mcp/refactor-seguro)
Your own site
<a href="https://agentmods.dev/commands/luanpdd/kit-mcp/refactor-seguro"><img src="https://agentmods.dev/badge/commands/luanpdd/kit-mcp/refactor-seguro.svg" alt="Measured on agentmods" height="20"></a>
Per session 49 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,505 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00049 $0.03505
Opus 5 $0.00024 $0.01752
Sonnet 5 $0.00010 $0.00701
Haiku 4.5 $0.00005 $0.00350

Measured 4d ago against content hash ce3d2280f981, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

refactor-seguro 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 4d 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.

kit/commands/refactor-seguro.md · 322 lines

How it starts

The opening of the file, as written. The whole thing — 322 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Chain padrão (--mode=full):

seam-finder → legacy-characterizer → refactor-safety-auditor → executor
   (se necessário)    (sempre)              (gate)               (refactor real)

Modos alternativos (atalhos quando mudança não justifica chain completo):

  • --mode=sprout — usa legacy-sprout-wrap-techniques; legado intocado, comportamento adicionado em sprout testado isoladamente
  • --mode=safe-extract — refactor mecânico (rename, IDE-extract bloco contíguo); checklist signed-off + sem characterization
  • --mode=override — bypass com audit trail (--ticket + --reason obrigatórios)

Cria/Atualiza:

  • Em modo full: .planning/SEAM-ANALYSIS.md, tests/characterization/<file_stem>/, .planning/REFACTOR-SAFETY.md
  • Em modo sprout: novo módulo + tests
  • Em modo safe-extract: refactor commit + checklist em .planning/SAFE-EXTRACT-<file>.md
  • Em modo override: .planning/REFACTOR-SAFETY.md com audit trail

Após: o user terminou refactor com confiança proporcional ao nível de safety net adotado.

Modos detalhados:

--mode=full (default)
=====================
1. /encontrar-seams <file>            (se necessário, deps externas presentes)
2. Aplicar técnicas de break-deps     (commits 1-N, manual ou via executor)
3. /caracterizar <file>                (gera safety net)
4. /auditar-refactor <file>           (gate retorna GO)
5. Refactor real                      (cover-and-modify, suite verde a cada commit)
6. Re-rodar suite final                (regressão = 0)

--mode=sprout
=============
1. AskUserQuestion para feature description
2. Aplicar legacy-sprout-wrap-techniques
3. Gerar sprout method/class testável
4. Conectar ao legado em 1-2 linhas
5. Tests do sprout (100% cobertura no novo)
6. PR criado com TODO de débito técnico (legado ainda untested)

--mode=safe-extract
====================
1. Validar checklist canônico:
   - Bloco a extrair é CONTÍGUO?
   - Sem control flow saindo do meio (return/throw/break)?
   - Variáveis lidas/escritas mapeadas?
   - Sem mover lógica entre escopos?
2. Aplicar refactor IDE-assisted
3. Compilação verde + smoke run
4. PR com SAFE-EXTRACT-<file>.md como artefato

--mode=override
================
1. Validar --ticket E --reason
2. Auditoria do refactor-safety-auditor com flag override
3. Audit trail registrado em REFACTOR-SAFETY.md
4. Refactor pode prosseguir SEM characterization
5. Débito técnico documentado no ticket

Exemplos:

/refactor-seguro src/orders/handler.ts                                # full chain (recomendado)
/refactor-seguro src/orders/handler.ts --mode=sprout                  # adicionar feature sem tocar legado
/refactor-seguro src/orders/handler.ts --mode=safe-extract            # rename/extract mecânico
/refactor-seguro src/orders/handler.ts --mode=override \
  --ticket REQ-2026-Q2-1234 --reason "hot fix SEV1, char em REQ-...1235"
/refactor-seguro src/orders/handler.ts --skip-seams                   # deps já testáveis
/refactor-seguro src/orders/handler.ts --symbol processOrder          # método específico

Read the full file on GitHub · 322 lines

Changes

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.

  1. 4d ago First seen · 322 lines · 49 tokens per session scan A ce3d2280f981

Subscribe to this mod's changes

refactor-seguro is a command published in the GitHub repository luanpdd/kit-mcp (1 stars, last pushed yesterday), licensed MIT. It adds 49 tokens to every session and 3,505 once invoked, about $0.0002 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-09-03.