---
name: aegis-tdd
description: Implement meaningful AEGIS features or regressions with one failing behavioral test and minimal implementation at a time. Use for TDD or test-first fixes; the existing testing skill owns Vitest harness details.
license: MIT
metadata:
  source: https://github.com/mattpocock/skills/blob/3cca18b368ae95cdbdebbff572ccafa662551015/skills/engineering/tdd/SKILL.md
title: aegis-tdd
canonical_url: https://skilld.dev/gh/antropos17/aegis/aegis-tdd
last_updated: 2026-10-27T06:30:44.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [agents/openai.yaml](https://skilld.dev/api/skills-raw/antropos17/aegis/aegis-tdd/agents/openai.yaml), [LICENSE](https://skilld.dev/api/skills-raw/antropos17/aegis/aegis-tdd/LICENSE).
>
> If the user asked to install this Skill, run `npx skilld install antropos17/aegis/aegis-tdd`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/aegis-tdd`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/antropos17/aegis/aegis-tdd) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/aegis-tdd`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/aegis-tdd --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/aegis-tdd --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# AEGIS test-driven changes

Adapted from Matt Pocock's tdd skill; attribution and terms: [LICENSE](https://skilld.dev/api/skills-raw/antropos17/aegis/aegis-tdd/LICENSE).

## Choose a contract already grounded in the project

Read the active checkout's AGENTS.md, current source and nearby tests. Use [aegis-context](../aegis-context/SKILL.md) for navigation and [testing](../testing/SKILL.md) for test harness conventions when available. If a worktree lacks these ignored local skills, read the checkout's package.json, Vite and Vitest configurations directly. Never choose a renderer directory from an old handoff alone.

Translate the user's request or existing documented invariant into an observable expectation. Choose the public boundary already used by the code, state it briefly, and proceed. No repeated approval is needed for an ordinary authorized test/fix. Ask only when unresolved expected behavior materially changes the implementation. Preserve concurrent work and do not delegate unless the user requests it.

## Put the test where the bug occurs

For main-process CommonJS code, native require needs the existing dependency seams/cache pattern; vi.mock alone is insufficient. Reuse init(deps), _setDepsForTest() and _resetForTest() where supported, and restore timers, mocks and shared state. For renderer tests, use the active Vitest project and its configured jsdom/Svelte environment. Match file extensions to the actual test include patterns.

The test boundary must reach the production caller and observe its output. Examples to select only when the change concerns them:

- Same PID reused by another process, or simultaneous same-named agents: observations remain attached to the correct instance.
- Observation outage followed by recovery: existing sessions are not falsely ended or split.
- Unknown ownership: no unrelated agent receives the event as a fallback.
- Audit overflow or unwritable storage: persisted-chain validity and loss visibility remain separate facts.
- IPC or renderer updates: the active consumer receives and displays the intended state; malformed or missing input follows its documented contract.

Read the relevant failure history in memory-bank/ai-mistakes.md. These examples identify test subjects; expected values come from the current request and code contracts, not a new policy invented by this skill.

## Red, green, then the next behavior

1. Write one meaningful behavioral test with an independent expected result. Run it with `npx vitest run <test-file>` and confirm it fails because of the intended behavior. A startup/import failure is not evidence that the regression is covered.
2. Implement the smallest change to satisfy that test. Avoid speculative APIs and bulk tests for imagined behavior.
3. Run the focused file and relevant neighbors. Small cleanup is allowed with tests green; architecture work requires its own task scope.

Use public behavior rather than private method calls, duplicated formulas or mocks that reproduce the implementation. Do not write tests for reversible low-impact edits that merely check wording or formatting. Existing tests can be extended instead of creating a parallel harness.

Do not deliberately break source or run mutation campaigns. Reproduce a reported defect against the existing behavior, then verify the intended fix with independently specified expectations. Reuse passing focused evidence until relevant inputs change.

## Honest completion

Follow the current verification requirements in AGENTS.md and CI. Check that the modified module is included in the applicable test/coverage project; a green suite that omits it is not coverage. Use npm run typecheck for configured projects and npm run typecheck:svelte for template checks. Root tsc --noEmit alone is insufficient.

State which behavior failed before, passed after and remains untested. Native/ETW tests need their own documented harness and authorization where applicable; synthetic and normal-token tests do not establish live-provider, elevation, sleep/wake or loss-free operation. Do not change tests, coverage thresholds or protected configuration merely to turn unrelated failures green.
