code-quality-refactoring

A set of practices for making code easier to understand and maintain while keeping its behavior unchanged.

In plain words
What is it for?
Use it to simplify code, split mixed responsibilities, remove repeated logic, and reduce complexity in focused changes.
Why use it?
It helps reduce duplication, tangled logic, oversized functions, and unclear responsibilities without requiring a broad rewrite.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/soden46/engineer-flow/code-quality-refactoring
Any agent
npx skills add soden46/engineer-flow --skill code-quality-refactoring
Clone the repo
git clone --depth 1 https://github.com/soden46/engineer-flow

Made for: Claude Code, Codex.

Per session 22 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 513 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00022 $0.00513
Opus 5 $0.00011 $0.00257
Sonnet 5 $0.00004 $0.00103
Haiku 4.5 $0.00002 $0.00051

Measured 2d ago against content hash 5ba0193304c1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

code-quality-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 2d 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.

skills/engineer-flow/core/code-quality-refactoring/SKILL.md · 122 lines

How it starts

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

Code Quality and Refactoring

Use this skill for cleanup, simplification, decomposition, duplication removal, complexity reduction, and maintainability improvements.

This skill is language and framework agnostic.

Preserve Behavior

Unless the task explicitly changes behavior, refactoring should preserve observable behavior.

Separate:

  • behavior changes
  • structural changes

when practical.

Scope

Prefer focused refactoring over broad rewrites.

Avoid touching unrelated code merely for style consistency.

Complexity

Reduce complexity where it materially improves understanding or correctness.

Potential signals include:

  • deeply nested control flow
  • large functions
  • duplicated logic
  • mixed responsibilities
  • hidden side effects
  • unclear state transitions
  • repeated mapping/validation logic
  • excessive branching

Do not optimize for arbitrary complexity numbers without considering readability.

Responsibilities

Keep distinct responsibilities separate when this improves clarity.

Common separations include:

  • validation
  • authorization
  • orchestration
  • persistence
  • transformation
  • external communication
  • presentation

Do not introduce abstractions merely to increase abstraction count.

Duplication

Remove meaningful duplicated behavior when shared behavior genuinely belongs together.

Some duplication may be preferable to premature coupling.

Naming

Names should communicate purpose rather than implementation trivia.

Prefer terminology already established by the project.

Dependencies

Avoid unnecessary dependencies between unrelated modules.

Prefer clear boundaries and explicit data flow.

Refactoring Safety

Before substantial refactoring:

  • identify expected behavior
  • identify relevant tests
  • understand external interfaces
  • preserve public contracts unless intentionally changed

After refactoring:

  • run relevant tests
  • verify behavior
  • check affected integration boundaries

Framework Adaptation

Follow the architectural conventions already used by the project.

Read the full file on GitHub · 122 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. 2d ago First seen · 122 lines · 22 tokens per session scan A 5ba0193304c1

Subscribe to this mod's changes

code-quality-refactoring is a skill published in the GitHub repository soden46/engineer-flow (3 stars, last pushed 5d ago), licensed MIT. It adds 22 tokens to every session and 513 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.

Related

Other skills, from other repositories

todos

This chat has a shared, live TODO plan — your tasks for the conversation, which the user also edits. Read this skill and reach for the todo tools whenever a request takes more than a couple of steps. It covers the plan model (group = task, items = its steps; loose items are the user's lane), how to work it: propose…

JetBrains/thinkrail · 127 tokens

writing-workflow-skills

Use when adding a new workflow skill to pi-thinkrail-workflow, changing an existing workflow skill's role, trigger, handoff, or structure, or checking a workflow skill against the workflow system's rules. Not for authoring general-purpose skills outside this package.

JetBrains/thinkrail · 60 tokens

brainstorming

Use this BEFORE any creative or feature work: building a new feature, adding functionality, changing behavior, or making a nontrivial design decision. Turns the user's request into a validated design — recorded as a spec-graph task-spec — before any implementation. Do not skip this because a change looks small.

JetBrains/thinkrail · 65 tokens

writing-specs

Use when a workflow step drafts or revises a spec artifact — a goal-and-requirements, an architecture, or a module SPEC — or when a workflow skill names it at such a step. The shared quality bar for specs — not a workflow, nothing to execute.

JetBrains/thinkrail · 59 tokens

clarify

Adaptive requirements clarification with auto-depth routing. Shallow (Q&A) for simple tasks, Deep (exploration + DRAFT + PLAN) for complex ones. Escalates automatically when ambiguity persists.

mag123c/toktrack · 43 tokens

review

Multi-agent code review for Rust CLI/TUI. UX Review inactive (terminal UI — no web frontend). Code Review only. Includes Rust/clippy-specific checklist.

mag123c/toktrack · 34 tokens