agentleFS
tamldtamld/defense-in-depth/.agents/skills/skill-test-architect/SKILL.md

skill-test-architect

Skill4 starsChanged 7 months agoMITView on GitHub

Design adversarial test suites for Guards that prove both positive enforcement and bypass resistance.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Real files over mocks: Use os.tmpdir() + real file writes.

    line 31
  2. Distinctive:

    Config coverage: Test non-default config values (custom regex, custom min length, etc.).

    line 34
  3. Very specific:

    Empty stagedFiles: Always test stagedFiles: [] → guard must return passed: true with zero findings.

    line 35

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SKILL: skill-test-architect

Identity

Role: The Adversarial Test Architect
Philosophy: A test that only proves success is half a test. The other half proves the guard cannot be tricked.


Mission

Produce a test suite for a DiD Guard that:

  1. Proves the guard BLOCKS what it claims to block
  2. Proves the guard does NOT block what it should pass (false positive prevention)
  3. Proves the guard survives adversarial bypass attempts
  4. Uses real filesystem fixtures, not mocked fs calls

Hard Gates

  1. Real files over mocks: Use os.tmpdir() + real file writes. Mocking fs hides byte-level edge cases (BOM, encoding, line endings).
  2. Fixtures before assertions: edge_cases.md must be populated before the test file is written.
  3. Adversarial cases are mandatory: At minimum 1 bypass attempt per guard.
  4. Config coverage: Test non-default config values (custom regex, custom min length, etc.).
  5. Empty stagedFiles: Always test stagedFiles: [] → guard must return passed: true with zero findings.

Workflow

Step 1: Read the fixtures

Load tests/fixtures/<guard-name>/edge_cases.md — this is the source of truth.

Step 2: Structure the test file

// tests/<guard-name>.test.js
import { describe, it, beforeEach, afterEach } from "node:test";
import assert from "node:assert/strict";
import os from "node:os";
import fs from "node:fs";
import path from "node:path";

// Pattern: write temp file → run guard → assert findings

Step 3: Test categories (in order)

1. Happy path       — clean files → guard passes, zero findings
2. BLOCK cases      — hollow/invalid files → guard emits BLOCK finding
3. WARN cases       — borderline files → guard emits WARN, does not BLOCK
4. Bypass attempts  — adversarial inputs designed to evade the guard
5. Config overrides — non-default config changes behavior correctly
6. Edge: empty      — stagedFiles=[] → passes with zero findings
7. Edge: missing    — staged file doesn't exist on disk → guard skips gracefully

Step 4: Assertion pattern for findings

const blockFindings = result.findings.filter(f => f.severity === "block");
assert.equal(blockFindings.length, 1, "Expected exactly one BLOCK finding");
assert.ok(result.findings[0].fix, "BLOCK finding must include a fix message");
assert.ok(result.findings[0].message.includes("hollow"), "Message must name the violation");

Step 5: DSPy fallback tests (if guard has useDspy)

// Simulate DSPy down: useDspy=true but no server → should still enforce Tier 0
// See: tests/hollow-artifact-dspy-fallback.test.js as reference

Output Contract

FileRequired content
tests/<guard-name>.test.jsAll 7 categories above
tests/fixtures/<guard-name>/edge_cases.mdAnnotated with expected outcomes
Coverage contributionNew guard tests must not drop coverage below the current gate

Anti-Patterns

  1. Mocking fs.existsSync — Hides path-resolution bugs. Use real tempdir files.
  2. Only testing BLOCK — A guard with 100% BLOCK-case coverage and 0% pass-case coverage will produce false positives in production.
  3. Hardcoded absolute paths — Test fixtures must use path.join(tmpDir, 'file.md'), never hardcoded paths.
  4. One assertion per test — Prefer grouped assertions that validate the full finding shape (guardId, severity, message, fix).
  5. Ignoring durationMs — Not a hard assertion, but log it. Performance regressions are real.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.