From aegis
Enforces Test-Driven Development for features and bugfixes: RED (write failing test), GREEN (minimal passing code), REFACTOR. Gates medium/high complexity to planning first.
npx claudepluginhub ganyuanran/aegis --plugin aegisThis skill uses the workspace's default tool permissions.
→ Implementing a feature or bugfix? → **No production code without a failing test first.**
Enforces strict Test-Driven Development (TDD): write failing test first for features, bug fixes, refactors before any production code.
Enforces strict TDD for features and bugfixes: RED (write minimal failing test), GREEN (minimal passing code), REFACTOR. No production code without failing test first.
Share bugs, ideas, or general feedback.
→ Implementing a feature or bugfix? → No production code without a failing test first. Gate: medium/high complexity? → route to brainstorming or writing-plans first. Cycle: RED (write test → watch it fail) → GREEN (minimal code → watch it pass) → REFACTOR (clean up → keep green) Regression: shared module → related tests. contract change → producer + consumer. core logic → old + new tests. → Done when: all tests pass, every new function has a test that failed first, TDD preflight gate passed.
Write the test first. Watch it fail. Write minimal code to pass.
If you didn't watch the test fail, you don't know if it tests the right thing.
New features, bug fixes, refactoring, behavior/logic changes, interface/data contract changes, cross-module or shared module changes, core logic refactors.
Exceptions (ask your human partner): throwaway prototypes, generated code, config files, pure docs cleanup, read-only diagnosis, comment-only changes.
TDD is the implementation discipline for an approved behavior or atomic task. It is not a substitute for task routing, product clarification, or planning.
Before writing tests or production code, stop and route to brainstorming or writing-plans if the current request has any medium- or high-complexity signal:
For these tasks, require a baseline read-set, plan, and atomic tasks before TDD. High-complexity or ambiguous tasks also need a spec/design review before planning. Only proceed directly with TDD for low-complexity work whose intent, owner, compatibility boundary, and verification path are already clear.
When a medium- or high-complexity task needs project records, use the Aegis
Project Workspace lazily. Prefer
python scripts/aegis-workspace.py init --root <target-project-root> when the
helper is available in the active method-pack checkout. If the task needs a
process trail under work/, prefer python scripts/aegis-workspace.py new-work --root <target-project-root> ...
so the intent, checkpoint, drift, and evidence paths are indexed and
structurally checkable:
docs/aegis/
README.md
INDEX.md
BASELINE-GOVERNANCE.md
adr/
baseline/
specs/
plans/
work/YYYY-MM-DD-<task-slug>/
10-intent.md
20-checkpoint.md
90-evidence.md
99-reflection.md
Do not promote reusable project facts, decisions, specs, or plans into those directories unless the workflow needs them and no existing project authority already owns them.
State: input | output | boundary | acceptance criteria. Check existing test coverage first. Write one minimal test showing what should happen.
```typescript 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 retryOperation(operation);
expect(result).toBe('success'); expect(attempts).toBe(3); });
Clear name, tests real behavior, one thing
</Good>
<Bad>
```typescript
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
Requirements:
MANDATORY. Never skip.
npm test path/to/test.test.ts
Confirm:
Test passes? You're testing existing behavior. Fix test.
Test errors? Fix error, re-run until it fails correctly.
Write simplest code to pass the test.
```typescript async function retryOperation(fn: () => Promise): Promise { 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( fn: () => Promise, options?: { maxRetries?: number; backoff?: 'linear' | 'exponential'; onRetry?: (attempt: number) => void; } ): Promise { // YAGNI } ``` Over-engineeredDon't add features, refactor other code, or "improve" beyond the test.
Fix the real owner of the behavior. Do not add a new fallback, adapter, or branch unless the debugging or design workflow identifies why it is necessary and what old path retires.
MANDATORY.
npm test path/to/test.test.ts
Confirm:
Test fails? Fix code, not test.
Other tests fail? Fix now.
After green only:
Keep tests green. Don't add behavior.
Next failing test for next feature.
At minimum, run the target test you just changed or added. Broaden regression based on impact:
If the current environment cannot run automated tests, state the blocker and provide reproducible manual verification steps.
| Quality | Good | Bad |
|---|---|---|
| Minimal | One thing. "and" in name? Split it. | test('validates email and domain and whitespace') |
| Clear | Name describes behavior | test('test1') |
| Shows intent | Demonstrates desired API | Obscures what code should do |
All of these mean: Delete code. Start over with TDD.
Bug: Empty email accepted
RED
test('rejects empty email', async () => {
const result = await submitForm({ email: '' });
expect(result.error).toBe('Email required');
});
Verify RED
$ npm test
FAIL: expected 'Email required', got undefined
GREEN
function submitForm(data: FormData) {
if (!data.email?.trim()) {
return { error: 'Email required' };
}
// ...
}
Verify GREEN
$ npm test
PASS
REFACTOR Extract validation for multiple fields if needed.
Can't check all boxes? Start over.
Exploratory spikes are allowed only as throwaway learning. When the spike ends, convert confirmed behavior into tests before formal implementation.
Emergency hotfixes may prioritize the smallest safe repair when delay is more dangerous than incomplete TDD. Record the reason, keep the change narrow, and add the missing regression test in the same slice or the next nearest slice.
Don't know how to test → write wished-for API first. Test too complicated → simplify design. Must mock everything → reduce coupling.
Bug found? Write failing test reproducing it. Follow TDD cycle. Never fix bugs without a test.