fastapi-refactor

fastapi-refactor is a skill for Claude Code from steph-dove/klaussy-agents. It costs 49 tokens per session (1,200 once invoked), scanned A, original, MIT.

A step-by-step method for reorganising a FastAPI codebase while keeping its existing behaviour unchanged. FastAPI is a Python framework for building web APIs.

In plain words
What is it for?
Use it to move or reorganise FastAPI code, add missing regression tests, inspect project rules, and verify the test suite after each change.
Why use it?
It requires a passing test baseline and incremental changes, so structural cleanup is less likely to introduce unnoticed regressions. It stops if the project is already failing before the refactor.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions CLAUDE.md; installed under .agents/ (shared by several agents).

Part of the klaussy plugin — 79 skills, 3 hooks, 1 MCP server shipped together

Good fit Use it to move or reorganise FastAPI code, add missing regression tests, inspect project rules, and verify the test suite after each change.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/steph-dove/klaussy-agents/fastapi-refactor
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.

Any agent
npx skills add steph-dove/klaussy-agents --skill fastapi-refactor
Clone the repo
git clone --depth 1 https://github.com/steph-dove/klaussy-agents

Made for: Claude Code.

Or install klaussy, the plugin that ships this one along with the rest of its 79 skills, 3 hooks, 1 MCP server.

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 fastapi-refactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/steph-dove/klaussy-agents/fastapi-refactor/github.svg)](https://agentmods.dev/skills/steph-dove/klaussy-agents/fastapi-refactor)
Your own site
<a href="https://agentmods.dev/skills/steph-dove/klaussy-agents/fastapi-refactor"><img src="https://agentmods.dev/badge/skills/steph-dove/klaussy-agents/fastapi-refactor/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.

agentmods 80×15 button for fastapi-refactor

Your own site · 80×15
<a href="https://agentmods.dev/skills/steph-dove/klaussy-agents/fastapi-refactor"><img src="https://agentmods.dev/badge/skills/steph-dove/klaussy-agents/fastapi-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 49 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,200 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.01200
Opus 5 $0.00024 $0.00600
Sonnet 5 $0.00010 $0.00240
Haiku 4.5 $0.00005 $0.00120

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

Security

Grade A, and why

fastapi-refactor 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 10d 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.

Origin

Copies of this mod

2 near-identical copies found in the catalogue:

examples/fastapi/.agents/skills/fastapi-refactor/SKILL.md · 88 lines

How it starts

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

Refactor the code the user described. The goal is to change structure while preserving behavior exactly. Do NOT change what the code does — only how it's organized.


Phase 1: Establish the Safety Net

Before changing any code, confirm you have tests that cover the current behavior.

  1. Read CLAUDE.md for project structure, test commands, and conventions.
  2. Read any .claude/rules/*.md whose paths: glob matches the area being refactored — they encode the conventions the moved code must continue to obey.
  3. Run the existing test suite. Record the results — every test must pass before you start. If tests are failing already, stop and report that. Do not refactor code that doesn't have a passing baseline.
  4. Assess coverage of the code you plan to change. Read the existing tests for the modules involved. If a function you're restructuring has no tests:
    • Write tests for its current behavior first.
    • Run them to confirm they pass.
    • These are your regression guardrails — they prove the refactor didn't break anything.

Phase 2: Understand the Current Code

Read the code you're refactoring in full. The three checks below are independent — issue them as a single batch of parallel tool calls, not sequentially:

  1. What it does — the inputs, outputs, side effects, and edge cases. Read the file(s) in full.
  2. Who calls it — grep for callers across the whole repo. Every caller is a contract you must preserve.
  3. What depends on its interface — function signatures, return types, exceptions thrown, event emissions. Grep for type/import references too. These are the things you cannot change without updating all consumers.

Phase 3: Plan the Refactor

Design the target structure before editing.

  1. Describe the structural change — what moves where, what gets renamed, what gets split or merged.
  2. List what must NOT change — public interfaces, return values, side effects, error behavior. Be explicit.
  3. Plan incremental steps. Break the refactor into the smallest possible moves that each leave the code in a working state. Never change behavior and structure in the same step. For example:
    • Step 1: Extract a function (tests still pass).
    • Step 2: Move the function to a new module (tests still pass).
    • Step 3: Update callers to use the new location (tests still pass).

Read the full file on GitHub · 88 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. 10d ago First seen · 88 lines · 49 tokens per session scan A 2803fc868a7e

Subscribe to this mod's changes

fastapi-refactor is a skill published in the GitHub repository steph-dove/klaussy-agents (16 stars, last pushed 13d ago), licensed MIT. It adds 49 tokens to every session and 1,200 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-08-30.