Borrowing it
Nothing to install: this file belongs to haakonbull/autosprint. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/haakonbull/autosprint/master/.claude/skills/python-refactoring/SKILL.mdgit clone --depth 1 https://github.com/haakonbull/autosprintWrote 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/haakonbull/autosprint/python-refactoring)<a href="https://agentmods.dev/skills/haakonbull/autosprint/python-refactoring"><img src="https://agentmods.dev/badge/skills/haakonbull/autosprint/python-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/haakonbull/autosprint/python-refactoring"><img src="https://agentmods.dev/badge/skills/haakonbull/autosprint/python-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.00042 | $0.02422 |
| Opus 5.5 | $0.00017 | $0.00969 |
| Sonnet 5.5 | $0.00008 | $0.00484 |
| Haiku 4.5 | $0.00004 | $0.00242 |
Grade A, and why
python-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 2mo 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 — 113 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Refactor the marked code (or the current file if nothing is marked) following these project rules:
Structure & Style
-
No wrapper functions for simple reads: Access config values directly. Do NOT create helper functions like
get_team_name()just to returnconfig.TEAM. Useconfig.TEAMdirectly where needed. -
No premature abstractions: Don't extract functions just to reduce line count. Three similar lines is better than a helper called only once. Do extract functions when they serve a structural purpose — avoiding nested try/except, giving a name to a distinct logical step, or keeping a function flat.
-
No separate variables for one-time values: If a value is only used once and is simple (a config read, a constant), inline it. Don't create
team_name = config.TEAMthree lines before its only use — just useconfig.TEAMdirectly. Exception: don't nest function calls likeextract_result(await run_query(...)). When one function's output feeds into another, use an intermediate variable so each step is debuggable on its own line. -
Imports: Prefer imports at the top of the file. Remove unused imports. Use
from autosprint.config import configfor config access. Lazy imports inside functions are acceptable when there's a good reason — optional dependencies that may not be installed, or circular imports. In those cases, add a comment explaining why. Use judgment: if the dependency is always available, move it to the top. -
Type hints: Add type hints to all function parameters, return types, and variables where the type isn't obvious from the assignment. Treat Python like TypeScript — everything should be typed. Use
from __future__ import annotationsat the top of each file for modern syntax. -
Every function gets a one-line docstring placed immediately after the
defline and before thetrykeyword. Exactly one line — no multi-line docstrings, no parameter tables, no type repetition. Describe the what, not the how.Phrasing by function kind (Command-Query Separation):
- Query (primary purpose is to return a value): start the docstring with
Returns <what it returns>. Example:"""Returns the current HEAD commit hash as a short string.""" - Command (primary purpose is a side effect — writes a file, calls an API, mutates state): start with an imperative verb describing the action. Example:
"""Append a sprint outcome line to ai-run.log.""" - Mixed (both returns something meaningful AND has a non-trivial side effect, e.g. mutates state or writes to disk): describe both briefly — action first, then what's returned. Example:
"""Run the Plan phase, write plan.md, and return (plan, next_task, sprints_since_replan)."""Prefer splitting such functions when practical.
Observability logging in queries is fine. A Query may call
printlevto log its decision, a cache hit/miss, or why it returned what it did. This is not a "Mixed" function — stdout/log output is observability, not state mutation. Treat the function as a Query for phrasing purposes (Returns ...), and optionally mention the log in the docstring if it's load-bearing. Example:"""Returns (True, reason) if plan.md should be regenerated and prints the reason; else (False, "")."""The CQS rule about "queries should not have side effects" is aimed at mutations (writing files, changing DB state, mutating arguments) — not at tracing what the function decided.On every refactor, verify the docstring is still an accurate summary of what the function does — if the function's behaviour drifted, rewrite the line; a stale one-liner is worse than none. Don't add other inline comments unless the logic isn't self-evident.
- Query (primary purpose is to return a value): start the docstring with
-
Prefer long lines over line breaks: Max line width is 1000. Do not manually break lines for readability — keep statements on a single line even if they're long. Let black handle formatting.
-
Bottom-up function ordering: Entry points (
main,if __name__) at the bottom. Leaf/utility functions near the top. Constants and module-level definitions at the very top after imports.
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.
- 2mo ago First seen · 113 lines · 42 tokens per session scan A 438842ad0b30
python-refactoring is a skill published in the GitHub repository haakonbull/autosprint (5 stars, last pushed 4d ago), licensed MIT. It adds 42 tokens to every session and 2,422 once invoked, about $0.0002 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.
python-refactoring compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| python-refactoringhaakonbull/autosprint | Skill | 5 | 4d ago | MIT | A | 42 | Claude Code |
| matlabK-Dense-AI/scientific-agent-skills | Skill | 56k | 4d ago | MIT | A | 44 | Claude Code |
| pennylaneK-Dense-AI/scientific-agent-skills | Skill | 56k | 4d ago | MIT | A | 74 | Claude Code |
| holoscan-install-wheelNVIDIA/skills | Skill | 3.9k | yesterday | Apache-2.0 | A | 34 | Claude Code, Codex |
| future-self-liteTHU-MAIC/OpenMAIC | Skill | 43k | yesterday | MIT | A | 20 | Claude Code, Codex |
| rocm-kernelshuggingface/kernels | Skill | 783 | yesterday | Apache-2.0 | A | 93 | Claude Code |
| typing-exclusion-workergetsentry/skills | Skill | 1.1k | yesterday | Apache-2.0 | A | 57 | Claude Code |