agentleFS
AvinashPAvinashP/AgentsAtlas/skills/testing/SKILL.md

testing

Skill7 starsChanged 9 months agoMITView on GitHub

Use when implementing any feature or bugfix - before writing implementation code. Write the test first, watch it fail, then implement.

123 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use oss-pr, pr-automation and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • CES-LtdSkill

    oss-pr

    Use when creating a pull request, after committing changes, or when user invokes /oss-pr. Covers branch management, quality checks, commit, push, and PR creation.

    Also in 3 projects that use this

  • CES-LtdSkill

    pr-automation

    PR Automation Orchestrator: poll open PRs, check CI, run review, fix, and merge eligible PRs. Use when: (1) Invoked by daemon via scripts/pr-automation.sh, (2) User says "/pr-automation".

    Also in 3 projects that use this

  • ffsshhttiikkSkill

    cicd

    Continuous integration and delivery pipelines

    Also in 4 projects that use this

  • ffsshhttiikkSkill

    networking

    Practical application and coding skills for Networking

    Also in 3 projects that use this

  • JohnJBorenSkill

    ci-cd

    CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies

    Also in 9 projects that use this

  • Cogni-AI-OUSkill

    dotfiles

    Reference for repository dotfiles, including their purposes, standard configurations, and usage guidelines. You MUST load this skill when configuring, troubleshooting, or understanding repository dotfiles.

    Also in 3 projects that use this

  • +2 more from CES-Ltd
  • +1 more from ffsshhttiikk

The file

We split this skill into the rules it gives an agent

10 rules. 0 are common, 10 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 105 edited versions we read keep these.

  • 10

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write the test first. Watch it fail.

    line 8
  2. Distinctive:

    If you didn't watch the test fail, you don't know if it tests the right thing.

    line 16
  3. Distinctive:

    Write code before the test?

    line 18
  4. Distinctive:

    Write one minimal test showing what should happen.

    line 39
  5. Distinctive:

    Test fails (not errors)

    line 72
  6. Distinctive:

    Write the simplest code to pass the test.

    line 80
  7. Distinctive:

    Don't add features, refactor other code, or "improve" beyond the test.

    line 104
  8. Distinctive:

    Keep tests green. Don't add behavior.

    line 128
  9. Distinctive:

    Test passes immediately (didn't watch it fail)

    line 138
  10. Distinctive:

    Test-first forces you to see the test fail, proving it actually tests something.

    line 169

“Common” is measured: kept by at least 6 in 10 of the 105 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Test-Driven Development

Write the test first. Watch it fail. Write minimal code to pass.

The Iron Law

NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST

If you didn't watch the test fail, you don't know if it tests the right thing.

Write code before the test? Delete it. Start over.

When to Use

Always:

  • New features
  • Bug fixes
  • Refactoring
  • Behavior changes

Exceptions (ask first):

  • Throwaway prototypes
  • Generated code
  • Configuration files

Thinking "skip TDD just this once"? Stop. That's rationalization.

Red-Green-Refactor

RED - Write Failing Test

Write one minimal test showing what should happen.

// Good: Clear name, tests real behavior, one thing
test('rejects empty email', async () => {
  const result = await submitForm({ email: '' });
  expect(result.error).toBe('Email required');
});
// Bad: Vague name, tests mock not code
test('form works', async () => {
  const mock = jest.fn().mockResolvedValue('success');
  await submitForm(mock);
  expect(mock).toHaveBeenCalled();
});

Requirements:

  • One behavior per test
  • Clear descriptive name
  • Real code (no mocks unless unavoidable)

Verify RED - Watch It Fail

MANDATORY. Never skip.

npm test path/to/test.test.ts

Confirm:

  • Test fails (not errors)
  • Failure message is expected
  • Fails because feature missing (not typos)

Test passes? You're testing existing behavior. Fix the test.

GREEN - Minimal Code

Write the simplest code to pass the test.

// Good: Just enough to pass
function validateEmail(email: string): string | null {
  if (!email?.trim()) return 'Email required';
  return null;
}
// Bad: Over-engineered
function validateEmail(
  email: string,
  options?: {
    allowEmpty?: boolean;
    customRegex?: RegExp;
    onValidate?: (email: string) => void;
  }
): ValidationResult {
  // YAGNI - don't add features not tested
}

Don't add features, refactor other code, or "improve" beyond the test.

Verify GREEN - Watch It Pass

MANDATORY.

npm test path/to/test.test.ts

Confirm:

  • Test passes
  • Other tests still pass
  • Output clean (no errors, warnings)

Test fails? Fix code, not test.

REFACTOR - Clean Up

After green only:

  • Remove duplication
  • Improve names
  • Extract helpers

Keep tests green. Don't add behavior.

Repeat

Next failing test for next feature.

Red Flags - STOP and Start Over

  • Code before test
  • Test after implementation
  • Test passes immediately (didn't watch it fail)
  • Can't explain why test failed
  • "I'll test after"
  • "Too simple to test"
  • "Just this once"
  • "Already manually tested it"
  • "Keep as reference" (delete means delete)

All of these mean: Delete code. Start over with TDD.

Common Rationalizations

ExcuseReality
"Too simple to test"Simple code breaks. Test takes 30 seconds.
"I'll test after"Tests passing immediately prove nothing.
"Already manually tested"Ad-hoc ≠ systematic. No record, can't re-run.
"Need to explore first"Fine. Throw away exploration, start with TDD.
"Test hard = skip it"Hard to test = hard to use. Simplify design.
"TDD will slow me down"TDD faster than debugging.
"Deleting X hours is wasteful"Sunk cost fallacy. Keeping unverified code is debt.

Why Order Matters

"I'll write tests after to verify it works"

Tests written after code pass immediately. Passing immediately proves nothing:

  • Might test wrong thing
  • Might test implementation, not behavior
  • You never saw it catch the bug

Test-first forces you to see the test fail, proving it actually tests something.

Quick Reference

Test Types

TypePurposeDependencies
UnitSingle function/methodMock externals
IntegrationMultiple componentsReal dependencies
E2EFull user workflowFull system

What to Test

Always test:

  • Happy path (normal usage)
  • Edge cases (empty, null, boundaries)
  • Error handling (invalid input, failures)

Skip testing:

  • Framework code (React, Express)
  • Third-party libraries
  • Simple getters/setters

Verification Checklist

Before marking complete:

  • Every new function has a test
  • Watched each test fail before implementing
  • Each test failed for expected reason
  • Wrote minimal code to pass each test
  • All tests pass
  • Tests use real code (mocks only if unavoidable)

Can't check all boxes? You skipped TDD. Start over.

Example: Bug Fix with TDD

Bug: Empty email accepted

RED

test('rejects empty email', async () => {
  const result = await submitForm({ email: '' });
  expect(result.error).toBe('Email required');
});

Verify RED

$ npm test
FAIL: expected 'Email required', got undefined

GREEN

function submitForm(data: FormData) {
  if (!data.email?.trim()) {
    return { error: 'Email required' };
  }
  // ...
}

Verify GREEN

$ npm test
PASS

REFACTOR - Extract validation if needed.

When Stuck

ProblemSolution
Don't know how to testWrite desired API first. Write assertion first.
Test too complicatedDesign too complicated. Simplify interface.
Must mock everythingCode too coupled. Use dependency injection.
Test setup hugeExtract helpers. Still complex? Simplify design.

See Also

  • frameworks.md - Framework-specific patterns (Jest, Vitest, Pytest)
  • patterns.md - Common test patterns and examples
  • anti-patterns.md - Testing mistakes to avoid

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.