testing-new-code

testing-new-code is a skill for Claude Code from gg-mo/repo-hygiene. It costs 56 tokens per session (1,029 once invoked), scanned A, original, MIT.

A testing rule for new or changed business logic, branching code, public API, or bug fixes. It requires tests before the change is committed; TDD means writing a failing test first, then the code that makes it pass.

In plain words
What is it for?
Use it when adding behavior, changing an existing function, fixing a bug, or adding a command, HTTP route, GraphQL field, or exported function.
Why use it?
Manual checks do not protect the behavior during later changes, so bugs can return without a recorded test.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the repo-hygiene plugin — 9 skills, 1 hook shipped together

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/gg-mo/repo-hygiene/testing-new-code
Any agent
npx skills add gg-mo/repo-hygiene --skill testing-new-code
Clone the repo
git clone --depth 1 https://github.com/gg-mo/repo-hygiene

Made for: Claude Code.

Or install repo-hygiene, the plugin that ships this one along with the rest of its 9 skills, 1 hook.

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 testing-new-code

README.md
[![agentmods](https://agentmods.dev/badge/skills/gg-mo/repo-hygiene/testing-new-code.svg)](https://agentmods.dev/skills/gg-mo/repo-hygiene/testing-new-code)
Your own site
<a href="https://agentmods.dev/skills/gg-mo/repo-hygiene/testing-new-code"><img src="https://agentmods.dev/badge/skills/gg-mo/repo-hygiene/testing-new-code.svg" alt="Measured on agentmods" height="20"></a>
Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,029 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.00056 $0.01029
Opus 5 $0.00028 $0.00515
Sonnet 5 $0.00011 $0.00206
Haiku 4.5 $0.00006 $0.00103

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

Security

Grade A, and why

testing-new-code 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 5d 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/testing-new-code/SKILL.md · 107 lines

How it starts

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

Testing New Code

Overview

In a repo using repo-hygiene, new code paths get tests before they're committed. The default is YES; "tests-after-if-asked" is the wrong default. Manual sanity checks are not tests — they leave no regression net for the next change.

Core principle: Untested code is one unrelated refactor away from broken.

REQUIRED BACKGROUND: If superpowers:test-driven-development is already active in this session, follow its RED-GREEN-REFACTOR cycle and consider this skill satisfied. Use this skill only when TDD is not driving the workflow.

When To Use

  • Wrote a new function with any branching or business logic
  • Fixed a bug (regression test required — see below)
  • Changed behavior of an existing function
  • Added a public API entry point (CLI, HTTP, GraphQL, exported function)

When NOT to Use (Genuine Triviality Only)

  • Pure renames, formatting, or type-annotation-only changes
  • Modifying a pass-through wrapper already tested at a higher layer
  • Adding a constant
  • Documentation-only changes
  • Test code itself

Not a valid exception: "It's only 3 lines." Three lines of business logic still need a test.

Bug Fixes Require Regression Tests

A bug fix without a regression test is incomplete. Verify the red-green cycle:

  1. Write the test against the pre-fix code → should FAIL
  2. Apply the fix → test should PASS
  3. Revert the fix once → test should fail again (proves it covers the bug)
  4. Re-apply the fix → test passes (final state)

If the test passes with the fix reverted, it isn't covering the bug.

Where Do Tests Live?

Mirror the repo's existing convention. If the repo has no tests yet, default to:

Language Default
JavaScript / TypeScript *.test.ts or *.spec.ts next to source, or __tests__/ sibling
Python tests/test_<module>.py at repo root
Go *_test.go next to source
Rust #[cfg(test)] mod tests { ... } in same file; tests/ for integration
Java / Kotlin src/test/... mirroring source

Read the full file on GitHub · 107 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. 5d ago First seen · 107 lines · 56 tokens per session scan A 6fc211a17598

Subscribe to this mod's changes

testing-new-code is a skill published in the GitHub repository gg-mo/repo-hygiene (3 stars, last pushed 3mo ago), licensed MIT. It adds 56 tokens to every session and 1,029 once invoked, about $0.0003 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

testing-principles

Language-agnostic testing principles including TDD, test quality, coverage standards, and test design patterns. Use when writing tests, designing test strategies, or reviewing test quality.

shinpr/claude-code-workflows · 40 tokens

specify-incremental

Decompose a single-feature specification into a linear, phase-by-phase implementation plan. Use this for medium-complexity work — single feature, one or two components — where transparent human-in-the-loop phase review is preferred over factory automation.

rsmdt/the-startup · 53 tokens

plan

Analyzes architecture, selects patterns, assesses testability, then decomposes work into ordered TDD tasks with exact verification commands and explicit acceptance mapping. Works from an approved spec (zuvo:brainstorm output) or directly from a user-provided description.

greglas75/zuvo · 53 tokens

unbiased-review

Use when reviewing a spec, plan, or implementation produced by another session - verifies its claims against the actual repo, grades TDD and hexagonal discipline, and reports severity-ranked findings without writing the fix. Triggers on "review this spec/plan/implementation", "second opinion on", "check this design"…

karsten-s-nielsen/mad-scientist-skills · 84 tokens

engineering-craft

Use when writing or changing any production code or tests — new features, bug fixes, refactors, or test authoring, in any language, by any model on any CLI.

mickeyyaya/evolve-loop · 40 tokens

tdd

Use when implementing features or bug fixes test-first.

Kripu77/software-factory · 13 tokens