agentleFS
modu-aimodu-ai/moai-adk/.claude/skills/moai-ref-testing-pyramid/SKILL.md

moai-ref-testing-pyramid

Skill1.2k starsChanged 3 months agoApache-2.0View on GitHub

Test pyramid strategy, coverage targets, test patterns, and quality metrics reference. Agent-extending skill that amplifies manager-develop test-creation and quality-validation work with production-grade testing patterns. NOT for: production code implementation, architecture design, DevOps, security audits.

Trending

Quiet since September.thin dataabout the whole repository

Jan 2026: 1 mentionFeb 2026: 0 mentionsMar 2026: 1 mentionApr 2026: 5 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 1 mentionAug 2026: 0 mentionsSep 2026: 3 mentionsOct 2026: 0 mentionsNov 2026: 0 mentionsDec 2026: 0 mentions
Jan 2026Jul 2026Dec 2026
Mentions a month of the modu-ai/moai-adk repository that our weekly crawl found: only 13 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about modu-ai/moai-adk

The biggest 5 of 13 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 13

Talked about on GitHub (13 times).

On GitHub · 13

8 more on GitHub

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    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:

    Never write production code without a failing test

    line 145
  2. Distinctive:

    Write the smallest test that fails

    line 146
  3. Distinctive:

    Write the simplest code that passes

    line 147
  4. Distinctive:

    DAMP over DRY: Test code should be descriptive and self-contained.

    line 162
  5. Distinctive:

    Test pyramid inverted: more E2E tests than unit tests

    line 169
  6. Distinctive:

    Test assertions check implementation details instead of behavior

    line 171
  7. Distinctive:

    No integration tests between unit and E2E layers

    line 172

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “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

Testing Pyramid Reference

Target Agents

  • manager-develop - Primary: applies patterns during test creation and coverage analysis
  • manager-develop - Secondary: applies during RED-GREEN-REFACTOR cycles

Test Pyramid Ratios

       /  E2E  \        10% — Critical user journeys only
      /----------\
     / Integration \    20% — API endpoints, DB queries, service boundaries
    /----------------\
   /    Unit Tests    \  70% — Functions, hooks, utilities, pure logic
  /--------------------\
LevelSpeedReliabilityMaintenanceCoverage Target
UnitFast (<100ms)HighLow70% of tests
IntegrationMedium (1-5s)MediumMedium20% of tests
E2ESlow (10-60s)LowerHigh10% of tests

Coverage Targets by Context

ContextTargetRationale
Critical business logic95%+Revenue/security impact
API endpoints90%+Contract compliance
Utility functions85%+Reuse reliability
UI components80%+Rendering correctness
Configuration/glue code60%+Low complexity
Generated code0%Don't test generated code

Test Pattern: AAA (Arrange-Act-Assert)

// Arrange: Set up test data and preconditions
input := CreateTestUser("test@example.com")

// Act: Execute the function under test
result, err := service.CreateUser(ctx, input)

// Assert: Verify the outcome
assert.NoError(t, err)
assert.Equal(t, "test@example.com", result.Email)

Unit Test Patterns

PatternWhenExample
Table-DrivenMultiple input/output combinationsGo: tests := []struct{...}
Mock/StubExternal dependencies (DB, API)Interface injection, mock frameworks
SnapshotComplex output comparisonJest snapshots, golden files
Property-BasedMathematical propertiesquickcheck, hypothesis
Boundary ValueEdge cases0, -1, MAX_INT, empty string, nil

Integration Test Patterns

PatternWhenExample
TestcontainersReal DB neededDocker-based PostgreSQL for tests
HTTP Test ServerAPI endpoint testinghttptest.NewServer (Go), supertest (Node)
In-Memory DBFast DB testsSQLite for development
Fixture LoadingConsistent test dataFactory functions, seed files

What to Test vs What NOT to Test

ALWAYS Test

  • Business logic and calculations
  • Input validation and error handling
  • Authentication and authorization flows
  • Data transformations and mappings
  • Edge cases and boundary conditions
  • Race conditions (with -race flag in Go)

NEVER Test

  • Framework internals (React rendering, Express routing)
  • Third-party library behavior
  • Simple getters/setters with no logic
  • Private methods directly (test via public API)
  • Generated code (protobuf, swagger)
  • CSS styling and layout (use visual regression tools instead)

Test Quality Metrics

MetricTargetTool
Line Coverage85%+go test -cover, istanbul, coverage.py
Branch Coverage75%+go test -covermode=count
Mutation Score70%+go-mutesting, Stryker
Test Execution Time<2 min (unit), <10 min (all)CI timer
Flaky Test Rate<1%CI history analysis

Test File Conventions

LanguageTest FileLocation
Go*_test.goSame package
TypeScript*.test.ts / *.spec.ts__tests__/ or co-located
Pythontest_*.pytests/ directory
Java*Test.javasrc/test/ mirror
Rust#[cfg(test)] mod testsSame file or tests/

TDD RED-GREEN-REFACTOR Quick Reference

RED:     Write a failing test that defines expected behavior
GREEN:   Write minimal code to make the test pass
REFACTOR: Clean up while keeping tests green

Rules:

  • Never write production code without a failing test
  • Write the smallest test that fails
  • Write the simplest code that passes
  • Refactor only when all tests are green
  • One assertion per test (when practical)
<!-- moai:evolvable-start id="rationalizations" -->

Common Rationalizations

RationalizationReality
"E2E tests cover everything, unit tests are redundant"E2E tests are slow and flaky. Unit tests provide fast, precise feedback. The pyramid exists because each level serves a different purpose.
"Integration tests are more realistic than unit tests"Realism comes at the cost of speed and isolation. A balanced pyramid gives both fast feedback and realistic validation.
"100% code coverage means the code is well tested"Coverage measures execution, not correctness. A test that executes code without meaningful assertions provides zero value.
"Mocking is bad, I prefer real dependencies"Real dependencies make tests slow and non-deterministic. Mock at boundaries, test business logic in isolation.
"This test is flaky, but it catches real bugs sometimes"Flaky tests erode trust in the entire suite. Fix the flakiness or quarantine the test with a tracking issue.

DAMP over DRY: Test code should be descriptive and self-contained. A reader should understand the test without reading shared fixtures or helper methods.

<!-- moai:evolvable-end --><!-- moai:evolvable-start id="red-flags" -->

Red Flags

  • Test pyramid inverted: more E2E tests than unit tests
  • Unit tests depend on external services (databases, APIs, file systems)
  • Test assertions check implementation details instead of behavior
  • No integration tests between unit and E2E layers
  • Flaky test present without a quarantine label or tracking issue
<!-- moai:evolvable-end --><!-- moai:evolvable-start id="verification" -->

Verification

  • Test distribution follows the pyramid: unit > integration > E2E (show test counts per category)
  • Unit tests run in under 30 seconds total
  • Integration tests mock external dependencies at the boundary
  • No flaky tests in the active suite (run 3x to verify stability)
  • Test names describe behavior, not implementation (review naming convention)
  • Coverage report shows meaningful assertions, not just line execution
<!-- moai:evolvable-end -->

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.