Example: The Testing Patterns Skill
Relevant source files
The following files were used as context for generating this wiki page:The testing-patterns skill is a core component of the Claude Code configuration that encapsulates the project's conventions for writing tests. Its primary purpose is to provide the AI agent with domain-specific knowledge on test structure, mocking strategies, and the Test-Driven Development (TDD) workflow. By activating this skill, Claude can generate or refactor test code that aligns with the repository's established patterns and quality standards.
This skill is part of a broader strategy to automate and standardize development practices, working alongside other skills like graphql-schema and react-ui-patterns. It is automatically suggested for activation by the Skill Evaluation System when a developer's prompt indicates an intent to write or modify tests.
Sources: README.md:9-12, .claude/skills/testing-patterns/SKILL.md, CLAUDE.md:46-47
Skill Configuration
The skill is defined in .claude/skills/testing-patterns/SKILL.md. The frontmatter of this file contains metadata that Claude uses to understand the skill's purpose and context.
| Field | Value | Description |
|---|---|---|
name | testing-patterns | A unique, lowercase identifier for the skill that matches its directory name. |
description | Jest testing patterns for this project. Use when writing tests, creating mocks, or following TDD workflow. | A critical field used by Claude to determine when the skill is relevant to a user's prompt. It includes keywords for semantic matching. |
Sources: .claude/skills/testing-patterns/SKILL.md:2-4, README.md:301-306
Skill Activation
The testing-patterns skill is activated both manually by developers and automatically by the project's skill evaluation hook. The CLAUDE.md file explicitly instructs developers to use this skill when creating tests.
The automated activation is managed by the skill-eval.sh hook, which is triggered on UserPromptSubmit. This script uses rules defined in .claude/hooks/skill-rules.json to match user intent against known skills.
Sources: CLAUDE.md:46-47, README.md:237-239, .claude/hooks/skill-rules.json:2-17
Activation Triggers
The following diagram illustrates the process of how the skill evaluation hook suggests activating the testing-patterns skill.
This flowchart shows the automated skill suggestion process on prompt submission.
Sources: README.md:237-249, README.md:273-284
The specific triggers for the testing-patterns skill are defined in .claude/hooks/skill-rules.json and include a combination of keywords, file path patterns, and intent analysis.
| Trigger Type | Patterns |
|---|---|
keywords | test, jest, spec, tdd, mock |
keywordPatterns | `\btest(?:s |
pathPatterns | **/*.test.ts, **/*.test.tsx |
intentPatterns | `(?:write |
Sources: .claude/hooks/skill-rules.json:6-15
Core Testing Principles
The skill document and the main project memory file (CLAUDE.md) outline several key principles for testing in this repository.
Test-Driven Development (TDD)
The project advocates for a TDD workflow where a failing test is written before the implementation code. This ensures that all new code is testable and meets its requirements from the outset.
The TDD workflow is as follows:
This diagram outlines the Test-Driven Development cycle encouraged by the project.
Sources: CLAUDE.md:42-43, .claude/skills/testing-patterns/SKILL.md:4
Test Structure
Tests should be organized logically using describe blocks for grouping related tests and it blocks for individual test cases. Each test case must follow the "Arrange, Act, Assert" (AAA) pattern.
- Arrange: Set up the initial state, variables, and mocks required for the test.
- Act: Execute the function or component being tested.
- Assert: Verify that the outcome of the action matches the expected result.
Sources: .claude/skills/testing-patterns/SKILL.md:8-10
Mocking
The preferred method for mocking is to use factory functions, such as getMockUser(overrides). This pattern allows for the creation of consistent mock data across tests while providing the flexibility to override specific fields for different test scenarios. The skill emphasizes mocking external dependencies rather than internal modules.
Sources: .claude/skills/testing-patterns/SKILL.md:13-15
Integration with Project Workflows
The testing-patterns skill is not an isolated tool; it is integrated into the broader development and code review workflow.
Code Review
The code-reviewer agent, defined in .claude/agents/code-reviewer.md, includes a checklist item to ensure that tests are included with any code changes. This reinforces the testing requirements defined in the testing-patterns skill during the review process.
## Checklist
- [ ] No TypeScript `any`
- [ ] Error handling present
- [ ] Tests included
Sources: .claude/agents/code-reviewer.md:15-17
Git Conventions
The CLAUDE.md file specifies that tests should be run before committing code, making testing a mandatory step in the local development cycle before code is even pushed.
Sources: CLAUDE.md:44
Summary
The testing-patterns skill is a foundational piece of the repository's automation and quality assurance strategy. It provides a single source of truth for testing conventions, enabling the Claude AI agent to act as a "super-powered teammate" that produces high-quality, compliant test code. Through automated activation hooks and integration with code review agents, this skill ensures that the project's testing standards are consistently applied, promoting a TDD culture and improving overall code reliability.
Sources: README.md:6-8, CLAUDE.md:42-47