agentleFS
MaxwellCalkinMaxwellCalkin/Autobot/.claude/skills/test-first/SKILL.md

test-first

Skill0 starsChanged 10 months agoMITView on GitHub

Test-first development practices for high-quality code

29 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use security-sweep, understand and 8 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.
  • paulocsbSkill

    security-sweep

    Comprehensive security audit of the app: RLS coverage, leaked secrets, auth flows, OWASP-style checks. Use periodically (before big releases, before onboarding many new friends, or after sensitive changes to policies/auth).

    Also in 3 projects that use this

  • agoodwaySkill

    understand

    Multi-specialist collaborative analysis to understand how features, functions, or components work

    Also in 3 projects that use this

  • danpegSkill

    bug-hunt

    Run adversarial bug hunting on your codebase. Uses 3 isolated agents (Hunter, Skeptic, Referee) to find and verify real bugs with high fidelity. Invoke with /bug-hunt, /bug-hunt [path], or /bug-hunt -b <branch> [--base <base>].

    Also in 3 projects that use this

  • GitHubSkill

    refactor

    Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.

    Also in 4 projects that use this

  • MicrosoftSkill

    api-design

    Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.

    Also in 3 projects that use this

  • Google CloudSkill

    triage

    Gather context on a change or bug and plan the implementation.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 24 edited versions we read keep these.

  • 3

    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:

    Before writing any implementation:

    line 29
  2. Distinctive:

    Write the simplest code that makes the test pass:

    line 47
  3. Distinctive:

    Don't add features: - Only what the test needs

    line 51

“Common” is measured: kept by at least 6 in 10 of the 24 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-First Development

The Red-Green-Refactor Cycle

    ┌─────────────────────────────────────┐
    │                                     │
    ▼                                     │
  [RED]                                   │
  Write a failing test                    │
    │                                     │
    ▼                                     │
  [GREEN]                                 │
  Write minimal code to pass              │
    │                                     │
    ▼                                     │
  [REFACTOR]                              │
  Improve code, keep tests green ─────────┘

Phase 1: RED - Write a Failing Test

Before writing any implementation:

  1. Define the behavior - What should happen?
  2. Write the test - Assert the expected outcome
  3. Run the test - Confirm it fails
  4. Verify the failure - It should fail for the right reason
// Good: Test defines behavior clearly
test('should reject invalid email', () => {
  const user = new User({ email: 'not-an-email' });
  expect(user.isValid()).toBe(false);
  expect(user.errors).toContain('Invalid email format');
});

Phase 2: GREEN - Make It Pass

Write the simplest code that makes the test pass:

  1. Don't over-engineer - Just make it work
  2. Don't optimize - That comes later
  3. Don't add features - Only what the test needs
// Minimal implementation to pass the test
class User {
  isValid() {
    return this.email.includes('@');
  }
}

Phase 3: REFACTOR - Improve the Code

With tests green, safely improve:

  1. Remove duplication - DRY up the code
  2. Improve naming - Make intent clear
  3. Simplify logic - Reduce complexity
  4. Run tests after each change - Stay green
// Refactored with better validation
class User {
  private static EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

  isValid() {
    return User.EMAIL_REGEX.test(this.email);
  }
}

Test Structure: AAA Pattern

test('descriptive name of behavior', () => {
  // Arrange - Set up test data
  const input = createTestInput();

  // Act - Execute the code under test
  const result = functionUnderTest(input);

  // Assert - Verify the outcome
  expect(result).toEqual(expectedOutput);
});

What to Test

Always Test

  • Happy path (normal operation)
  • Edge cases (empty, null, boundary values)
  • Error cases (invalid input, failures)
  • State transitions
  • Public API contracts

Sometimes Test

  • Complex private methods (via public API)
  • Integration points
  • Performance-critical paths

Never Test

  • Third-party library behavior
  • Trivial getters/setters
  • Framework internals
  • Implementation details

Test Quality Checklist

  • Test name describes the behavior, not implementation
  • Test is independent (no shared mutable state)
  • Test has one logical assertion
  • Test fails for the right reason
  • Test is deterministic (no flakiness)
  • Test runs fast (< 100ms for unit tests)

Common Patterns

Testing Async Code

test('fetches user data', async () => {
  const user = await fetchUser(123);
  expect(user.name).toBe('Alice');
});

Testing Errors

test('throws on invalid input', () => {
  expect(() => parseDate('invalid')).toThrow('Invalid date format');
});

Testing Side Effects

test('logs error on failure', () => {
  const mockLogger = jest.fn();
  processData(invalidData, { logger: mockLogger });
  expect(mockLogger).toHaveBeenCalledWith('Error processing data');
});

Anti-Patterns to Avoid

  • Test implementation, not behavior - Tests break on refactor
  • Multiple assertions testing different things - Hard to diagnose
  • Shared mutable state - Flaky, order-dependent tests
  • Testing private methods directly - Couples to implementation
  • Excessive mocking - Tests pass but code is broken

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.