
test-driven-development
✓ Official★ 4,933by microsoft · part of microsoft/fluidframework
Tests first, code second — because a test you never watched fail might not be testing anything at all.
WHEN YOUR AGENT SHOULD USE IT
A QUICK BOUNDARYUSE FOR
- Write a failing test first so you know it actually exercises the missing behavior.
- Catch a test that only checks a mock instead of real behavior before it's kept.
- Write the smallest amount of code needed to make a new test pass.
- Refactor cleanly once tests are green, without changing any behavior.
- Switch to a debugging skill instead of looping on a failing fix three times.
This is the playbook your agent receives when the skill activates — you don't need to read it to use the skill, but it's here to audit before installing.
-
Write failing tests (RED phase)
-
Create a subagent using the nori-task-runner to evaluate test quality.
- Ensure that each test does not just test mocks. If it does, remove the test and try again.
- Ensure each test does not test implementation detail. If it does, rewrite the test so that it tests boundary behavior.
- Ensure each test does not test data structure format or types. If it does, remove the test and try again.
- Ensure each test does not test for removed behavior. For example, if some behavior has been deprecated, do not write a test that simply confirms the behavior no longer works.
- Evaluate if the test treats the interior of the test boundary as a blackbox. You should not know anything about interior variables, function calls, or control flow.
- Verify the test fails due to the behavior of the application, and NOT due to the test. If you have more than one test that you need to write, you should write all of them before moving to the GREEN phase.
- Write the minimal amount of code necessary to make the test pass (GREEN phase)
- Verify the test now passes due to the behavior of the application.
- If you go through three loops without making progress, switch to running
.claude/skills/creating-debug-tests-and-iterating
- If you go through three loops without making progress, switch to running
- Refactor the code to clean it up.
- Verify tests still pass.
RED - Write Failing Test
Write one minimal test showing what should happen.
test('retries failed operations 3 times', async () => {
let attempts = 0;
const operation = () => {
attempts++;
if (attempts < 3) throw new Error('fail');
return 'success';
};
const result = await foobar.retryOperation(operation);
expect(result).toBe('success');
expect(attempts).toBe(3);
});Clear name, tests real behavior, one thing. Note that the tested operation is imported -- this is a STRONG sign that this is testing something real.
test('retry works', async () => {
const mock = jest
.fn()
.mockRejectedValueOnce(new Error())
.mockRejectedValueOnce(new Error())
.mockResolvedValueOnce('success');
await retryOperation(mock);
expect(mock).toHaveBeenCalledTimes(3);
});Vague name, tests mock not code
Verify RED - Watch It Fail
npm test path/to/test.test.tsConfirm:
- Test fails (not errors)
- Failure message is expected
- Fails because feature missing (not typos)
GREEN - Minimal Code
Write simplest code to pass the test.
```typescript async function retryOperation<T>(fn: () => Promise<T>): Promise<T> { for (let i = 0; i < 3; i++) { try { return await fn(); } catch (e) { if (i === 2) throw e; } } throw new Error('unreachable'); } ``` Just enough to pass ```typescript async function retryOperation<T>( fn: () => Promise<T>, options?: { maxRetries?: number; backoff?: 'linear' | 'exponential'; onRetry?: (attempt: number) => void; } ): Promise<T> { // YAGNI } ``` Over-engineeredDon't add features, refactor other code, or "improve" beyond the test.
Verify GREEN - Watch It Pass
npm test path/to/test.test.tsConfirm:
- Test passes
- Other tests still pass
- Output pristine (no errors, warnings)
REFACTOR - Clean Up
After green only:
- Remove duplication
- Improve names
- Extract helpers
Keep tests green. Do not add behavior.
Install this skill from microsoft/fluidframework on GitHub. It only works when installed from that project, so don't copy the skill's file out on its own.
npx skills add microsoft/fluidframework --skill "test-driven-development" --full-depthRun this in your project — your agent picks the skill up automatically.
BEFORE IT WILL WORK
Nothing — it works as soon as it is installed.
Licensed under MIT— you can use, modify, and redistribute it under that license's terms.
View the full license file on GitHub →