Skip to content

oprogramadorreal/optimus-claude / skills/tdd

Guides test-driven development — decomposes a feature or bug fix into testable behaviors, then runs Red-Green-Refactor cycles with a failing test before every implementation. Auto-detects specs from docs/specs/ or docs/jira/, creates a feature branch (optional worktree), commits per cycle, and pushes. Recommends /optimus:init (falls back to general best practices on your choice); requires a passing test suite.

FileKindSize
README.mdmarkdown5.3 KB
SKILL.mdskill md20.4 KB
agents/openai.yamlconfig198 B
references/testing-anti-patterns.mdmarkdown2.1 KB

references/testing-anti-patterns.md

View on GitHub
# Testing Anti-Patterns

Read when writing or reviewing tests — especially before adding mocks.

**Test what the code does, not what the mocks do.** Mocks isolate; they are never the thing under test. Four questions catch nearly every violation.

### 1. "Am I asserting on the mock or on the code under test?"

- Bad: `expect(screen.getByTestId('sidebar-mock')).toBeInTheDocument()` — proves the mock renders, not that the page works.
- Good: don't mock the sidebar — `expect(screen.getByRole('navigation')).toBeInTheDocument()`.

### 2. "Does this test depend on side effects I've mocked away?"

Before mocking, know what the real method does and whether the test depends on any of it. If it does, mock at a lower level or use the real implementation.

- Bad: mocking `ConfigManager.saveConfig` in a duplicate-server test — the duplicate check reads the config the mock never wrote, so the expected error never fires.
- Good: mock only the slow network client; let the config write happen for real.

### 3. "Can this test use the real implementation?"

Only mock what you must: external services (APIs, databases), non-deterministic behavior (time, randomness), and slow I/O. If the real code is fast and deterministic, use it.

Over-mocking shows up as mock setup longer than the test logic, tests that break when the mock changes while the real code is fine, mocks of internal modules rather than external services, mock data missing fields the real API returns, and mocks added "just to be safe" that nobody can justify.

### 4. "Am I verifying through the public interface or a backdoor?"

- Bad: `db.query('SELECT * FROM users WHERE name = ?', ['Alice'])` to check that `createUser` saved — couples the test to a storage decision; a schema change breaks it while the code still works.
- Good: `getUser(user.id)` — read the result back through the API the system exposes. If no interface exists to read it back, that is a design gap.

## Also

A method that exists only for tests to call (`destroy()`, `reset()`) belongs in test utilities, not on the production class — it pollutes the public API and is dangerous if something calls it for real.
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall