Skip to main content
skill CX Codex

testing-expert — Claude Code skill: unit, integration and E2E tests

testing-expert — a skill that gives the agent rules for writing tests: AAA structure, isolated cases, doubles and edge cases. TDD and BDD theory sits in a reference file the agent opens only when needed.

Apache-2.0 206 installs ★ 45 updated 2026-10-12

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add personamanagmentlayer/pcl --skill testing-expert -a claude-code
Open on GitHub

What testing-expert does

The skill is a set of conventions the agent follows while writing tests. It covers the Arrange-Act-Assert split, keeping cases independent of run order, names that describe the behaviour (should throw error when ID is negative), and one assertion per behaviour. Stubs, mocks and spies each get a note on when they fit.

Fixtures and factory helpers are covered too, along with beforeAll/afterEach hooks and the awkward inputs: empty arrays, zero, division by zero, floating point, very large numbers. There is advice on keeping the suite quick, by shrinking the dataset or mocking an expensive call. Deeper material on TDD, BDD and the unit/integration/E2E split lives in references/CORE_CONCEPTS.md and is read on demand.

The tool list is narrow. Bash is granted only for test runners (npm, pytest, jest, vitest, go test, mvn test, gradle test), so a shell command outside that list, say docker compose up, will not run under this skill. On coverage the author's guidance is 80%+ and no chase for 100%.

What it helps with

  • write unit tests before the function exists
  • split a bloated test into arrange, act and assert
  • stop tests from depending on each other's run order
  • swap a real database call for a stub or a spy
  • cover boundary inputs: zero, empty array, negative ID

Example prompts for the agent

  • Write the tests for calculateTotal TDD-style: failing test first, then the implementation
  • Break this test into independent cases and give them descriptive names
  • Add an E2E test for checkout and mock the payment API

How to install testing-expert

1Skills CLI (Vercel)

npx skills add personamanagmentlayer/pcl --skill testing-expert -a claude-code

2Manually: put the files in place

~/.claude/skills/testing-expert/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/testing-expert/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about testing-expert

How do I install testing-expert in Claude Code?

Run npx skills add personamanagmentlayer/pcl --skill testing-expert -a claude-code. The skill file lands at ~/.claude/skills/testing-expert/SKILL.md.

What does testing-expert do?

It hands the agent testing conventions: AAA structure, isolated cases, naming, test doubles and edge cases. Background on TDD, BDD and the test levels is in references/CORE_CONCEPTS.md.

Does it work outside Claude?

Yes. The same repository installs for Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode, each with its own command from the install list.

Source text

SKILL.md · Apache-2.0
---
name: testing-expert
version: 1.1.0
description: >-
  Expert-level software testing with unit tests, integration tests, E2E tests, TDD/BDD, and
  testing best practices. Use when the user mentions TDD, BDD, unit tests, integration
  tests, or end-to-end tests, or when the task involves Testing Fundamentals, Unit Testing,
  Integration Testing, or End-to-End Testing.
category: tools
author: PCL Team
license: Apache-2.0
tags:
  - testing
  - tdd
  - bdd
  - unit-tests
  - integration-tests
  - e2e
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash(npm:*, pytest:*, jest:*, vitest:*, go test:*, mvn test:*, gradle test:*)
  - Glob
  - Grep
---

# Testing Expert

You are an expert in software testing with deep knowledge of testing methodologies, frameworks, and best practices. You write comprehensive test suites that ensure code quality, prevent regressions, and document expected behavior.

## Best Practices

### 1. AAA Pattern (Arrange-Act-Assert)

```typescript
test('should calculate total price', () => {
  // Arrange - Set up test data
  const cart = new ShoppingCart();
  cart.addItem({ name: 'Book', price: 10 });
  cart.addItem({ name: 'Pen', price: 2 });

  // Act - Execute the behavior
  const total = cart.calculateTotal();

  // Assert - Verify the outcome
  expect(total).toBe(12);
});
```

### 2. Test Independence

```typescript
// Bad - tests depend on order
test('create user', () => {
  userId = createUser('Alice'); // Global state
});

test('get user', () => {
  const user = getUser(userId); // Depends on previous test
  expect(user.name).toBe('Alice');
});

// Good - each test is independent
test('create user', () => {
  const userId = createUser('Alice');
  expect(userId).toBeGreaterThan(0);
});

test('get user', () => {
  const userId = createUser('Bob'); // Own setup
  const user = getUser(userId);
  expect(user.name).toBe('Bob');
});
```

### 3. Test Naming

```typescript
// Bad
test('test1', () => { ... });
test('user test', () => { ... });

// Good - descriptive names
test('should return user when ID exists', () => { ... });
test('should throw error when ID is negative', () => { ... });
test('should create user with valid email', () => { ... });
```

### 4. One Assertion Per Test (Generally)

```typescript
// Acceptable for related assertions
test('should create user with correct data', () => {
  const user = createUser({ name: 'Alice', email: '[email protected]' });

  expect(user.id).toBeGreaterThan(0);
  expect(user.name).toBe('Alice');
  expect(user.email).toBe('[email protected]');
  expect(user.createdAt).toBeInstanceOf(Date);
});

// Better - split if testing different behaviors
test('should assign ID to new user', () => {
  const user = createUser({ name: 'Alice', email: '[email protected]' });
  expect(user.id).toBeGreaterThan(0);
});

test('should set creation timestamp', () => {
  const user = createUser({ name: 'Alice', email: '[email protected]' });
  expect(user.createdAt).toBeInstanceOf(Date);
});
```

### 5. Use Test Doubles Appropriately

```typescript
// Stub - Returns predefined values
const stub = {
  getUser: () => ({ id: 1, name: 'Alice' }),
};

// Mock - Records interactions and can verify them
const mock = vi.fn().mockReturnValue({ id: 1, name: 'Alice' });
service.getUser(1);
expect(mock).toHaveBeenCalledWith(1);

// Spy - Wraps real object and records calls
const spy = vi.spyOn(database, 'query');
service.getUser(1);
expect(spy).toHaveBeenCalled();
```

### 6. Test Edge Cases

```typescript
describe('divide', () => {
  it('should divide positive numbers', () => {
    expect(divide(10, 2)).toBe(5);
  });

  it('should divide negative numbers', () => {
    expect(divide(-10, 2)).toBe(-5);
  });

  it('should throw error on division by zero', () => {
    expect(() => divide(10, 0)).toThrow('Division by zero');
  });

  it('should handle floating point division', () => {
    expect(divide(1, 3)).toBeCloseTo(0.333, 2);
  });

  it('should handle very large numbers', () => {
    expect(divide(Number.MAX_SAFE_INTEGER, 2)).toBeGreaterThan(0);
  });
});
```

### 7. Keep Tests Fast

```typescript
// Bad - slow tests
test('process large dataset', async () => {
  const data = Array.from({ length: 1000000 }, (_, i) => i);
  await processData(data); // Takes 10 seconds
});

// Good - use smaller datasets or mock
test('process large dataset', async () => {
  const data = Array.from({ length: 100 }, (_, i) => i);
  await processData(data); // Takes 10ms
});

// Or mock the expensive operation
test('process large dataset', async () => {
  const mockProcess = vi.fn().mockResolvedValue('processed');
  await processDataWithDependency(mockProcess);
  expect(mockProcess).toHaveBeenCalled();
});
```

## Common Patterns

### Test Fixtures

```typescript
// Shared test data
const testUsers = {
  alice: { id: 1, name: 'Alice', email: '[email protected]' },
  bob: { id: 2, name: 'Bob', email: '[email protected]' },
};

// Factory functions
function createTestUser(overrides = {}) {
  return {
    id: 1,
    name: 'Test User',
    email: '[email protected]',
    createdAt: new Date(),
    ...overrides,
  };
}
```

### Setup and Teardown

```typescript
describe('Database tests', () => {
  beforeAll(async () => {
    // Runs once before all tests
    await database.connect();
  });

  afterAll(async () => {
    // Runs once after all tests
    await database.disconnect();
  });

  beforeEach(async () => {
    // Runs before each test
    await database.clear();
  });

  afterEach(() => {
    // Runs after each test
    vi.clearAllMocks();
  });
});
```

## Approach

When writing tests:

1. **Write Tests First** (TDD) or with code
2. **Test Behavior, Not Implementation**: Focus on what, not how
3. **Keep Tests Simple**: Tests should be easier to understand than code
4. **Use Descriptive Names**: Test name = documentation
5. **Test Edge Cases**: Nulls, empty arrays, boundary values
6. **Mock External Dependencies**: Databases, APIs, file system
7. **Maintain Tests**: Refactor tests with production code
8. **Aim for Coverage**: 80%+ but don't chase 100%

Always write tests that are fast, reliable, isolated, and maintainable. Good tests are the best documentation for your code.

## Reference Documentation

Detailed material lives alongside this skill and is read on demand:

- [Core Expertise](references/CORE_CONCEPTS.md) — Testing Fundamentals, Unit Testing, Integration Testing, End-to-End Testing, Test-Driven Development (TDD), Behavior-Driven Development (BDD)

© PCL Team · Apache-2.0 · personamanagmentlayer/pcl

Similar skills

All skills for Testing and QA →

From the same set104

The whole set →
databricks-expert databricks-expert hands the agent Databricks practice for clusters, Delta Lake, PySpark and MLflow. Useful when a pipeline crawls or a join falls apart. CX Codex +1 215installs kubernetes-expert kubernetes-expert guides cluster operations, deployment manifests, network debugging, and Helm chart setups. Useful for DevOps engineers and container deployments. CX Codex +1 215installs spring-boot-expert spring-boot-expert guides coding agents through Spring Boot development, REST API design, and microservice setup in Java projects. CX Codex +1 212installs devops-expert devops-expert puts working CI/CD, infrastructure-as-code and release-strategy patterns in front of the agent whenever a task touches pipelines, automation or DevOps culture. CX Codex +1 210installs sre-expert sre-expert guides site reliability engineering practices, incident workflows, and error budget calculations. CX Codex +1 205installs elasticsearch-expert elasticsearch-expert is a Claude Code skill that helps design Elasticsearch mappings, build search queries and aggregations, and optimize ELK stacks. CX Codex +1 205installs prometheus-expert prometheus-expert — a skill that gives your coding agent solid Prometheus knowledge: metric collection, PromQL, recording and alerting rules. Useful when exporters have to go up on Kubernetes or a query just will not return what you expect. CX Codex +1 204installs kotlin-expert The kotlin-expert skill guides Kotlin work across Android, coroutines, JVM, and Kotlin Multiplatform. Use it when an agent needs help with Kotlin syntax, architecture, or asynchronous code. CX Codex +1 203installs

Project sponsors

Companies that keep this analytics open