tidy-first

tidy-first is a command for Claude Code, Gemini CLI from mfmezger/ai_agent_dotfiles. It costs 81 tokens per session (1,389 once invoked), scanned A, original, MIT.

A coding workflow based on Kent Beck’s “Tidy First” approach, which separates code reorganization from changes that alter behavior.

In plain words
What is it for?
Use it when renaming code, extracting methods, moving files, reorganizing modules, adding features, fixing bugs, or combining refactoring with behavior changes.
Why use it?
Keeping structural edits separate makes it easier to review refactors and determine whether a later change introduced a bug.

Command for Claude CodeGemini CLI

Written for Gemini CLI and Claude Code: installed under .gemini/, but also a Claude Code command (commands/*.md).

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 commands/mfmezger/ai_agent_dotfiles/tidy-first
Clone the repo
git clone --depth 1 https://github.com/mfmezger/ai_agent_dotfiles

Made for: Claude Code, Gemini CLI.

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 tidy-first

README.md
[![agentmods](https://agentmods.dev/badge/commands/mfmezger/ai_agent_dotfiles/tidy-first.svg)](https://agentmods.dev/commands/mfmezger/ai_agent_dotfiles/tidy-first)
Your own site
<a href="https://agentmods.dev/commands/mfmezger/ai_agent_dotfiles/tidy-first"><img src="https://agentmods.dev/badge/commands/mfmezger/ai_agent_dotfiles/tidy-first.svg" alt="Measured on agentmods" height="20"></a>
Per session 81 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,389 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.1 $0.00081 $0.01389
Opus 5 $0.00041 $0.00694
Sonnet 5 $0.00016 $0.00278
Haiku 4.5 $0.00008 $0.00139

Measured 6d ago against content hash 82f76958d310, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

tidy-first 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 6d 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.

gemini/.gemini/commands/tidy-first.md · 176 lines

How it starts

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

Tidy First

Follow Kent Beck's "Tidy First" approach by strictly separating structural changes from behavioral changes in all development work.

Source

This skill is adapted from the community skill snrsw-dotfiles-tidy-first on the LobeHub Skills Marketplace.

The instructional content below is the original skill's guidance, lightly reformatted for this dotfiles repo. Marketplace install/registration steps from the upstream page are intentionally omitted — this skill ships directly via shared/skills/ and is synced to each tool by scripts/sync-skills.sh.

Core Principle

Separate all changes into two distinct types:

  1. Structural changes — rearranging code without changing behavior:

    • Renaming variables, functions, classes
    • Extracting methods or functions
    • Moving code to different files or modules
    • Reorganizing code structure
    • Improving code organization
  2. Behavioral changes — adding or modifying actual functionality:

    • Adding new features
    • Fixing bugs
    • Changing business logic
    • Modifying functionality

Golden Rules

Never mix change types

  • Never mix structural and behavioral changes in the same commit.
  • Each commit is either purely structural OR purely behavioral.
  • This makes code review easier and debugging simpler.

Structural changes first

  • When both kinds of change are needed, always do the structural changes first.
  • Tidy the code before adding new behavior.
  • Prepare the structure to receive new functionality.

Validate structural changes

  • Validate that structural changes do not alter behavior.
  • Run all tests before making the structural change.
  • Run all tests after making the structural change.
  • Tests must pass with the same results before and after. If behavior changed, it was not a pure structural change.

Read the full file on GitHub · 176 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. 6d ago First seen · 176 lines · 81 tokens per session scan A 82f76958d310

Subscribe to this mod's changes

tidy-first is a command published in the GitHub repository mfmezger/ai_agent_dotfiles (5 stars, last pushed 1mo ago), licensed MIT. It adds 81 tokens to every session and 1,389 once invoked, about $0.0004 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.