agh-test-conventions

$npx mdskill add compozy/agh/agh-test-conventions

Enforce Go test shape rules after placement is justified.

  • Ensures new Go tests have a justified invariant, layer, and suite.
  • Depends on consolidate-test-suites and test-shape-rules.md reference.
  • Applies shape rules only after placement is confirmed by consolidate-test-suites.
  • Outputs a done condition confirming all shape rules are applied.

SKILL.md

.github/skills/agh-test-conventionsView on GitHub ↗
---
name: agh-test-conventions
description: >-
  Go test-shape discipline for AGH. Use when writing or editing *_test.go under
  cmd or internal after test placement is justified. Do not use for non-Go
  tests, fixture-only changes, or as a replacement for consolidate-test-suites.
trigger: implicit
---

# AGH Test Conventions

Apply Go-specific shape rules only after `consolidate-test-suites` identifies
the invariant, owning layer, and canonical suite. This file owns the application
order; its reference owns the rules.

## Procedures

**Step 1: Confirm Placement**

1. Use `consolidate-test-suites` before creating a new Go test file, moving coverage, or adding tests primarily for a task checklist or coverage target.
2. Record the invariant, owning layer, and canonical suite before applying Go-specific shape rules.
3. If no invariant or owning layer exists, stop. Do not add a Go test just to raise coverage.

*Done when:* one durable invariant, one owning layer, and one canonical suite are recorded for every changed test.

**Step 2: Load the Canonical Shape**

1. Determine whether the edit creates a new test file, adds cases to an existing test, or refactors an existing test.
2. Read the existing canonical suite and `.agents/skills/agh/agh-test-conventions/references/test-shape-rules.md` in full.
3. Apply every matching rule for subtests, parallelism, errors, assertions, interfaces, build tags, integration/E2E behavior, mocks, coverage, helpers, and race/cgo.

*Done when:* each changed case conforms to every matching reference section and no duplicate invariant was added.

**Step 3: Preserve the Runtime Contract**

1. Co-ship ACP/E2E fixtures, typed matchers, generated contracts, and cross-surface expectations when runtime behavior changes.
2. Use real SQLite, subprocess mocks, and other production-like boundaries where the owning layer requires them.
3. Treat a failing assertion as evidence about production behavior; repair production code unless the test is proven invalid against the contract.

*Done when:* the test exercises the real owner closely enough to fail on the named regression and all changed runtime-contract fixtures agree.

**Step 4: Validate the Changed Suite**

1. Run the read-only checker with its repo-root path:
   `python3 .agents/skills/agh/agh-test-conventions/scripts/check-test-conventions.py <file_path>`
2. Fix real findings; document a proven heuristic false positive without weakening the canonical rules.
3. Run `go test -race ./<owning-package>/...` for the affected package with `CGO_ENABLED=1`, then the required scoped lint lane.
4. Reserve the single full `make verify` for the task completion gate after source freeze.

*Done when:* the checker and scoped race/lint lanes are green and exactly one fresh full gate is scheduled or complete for the finished task.

## Error Handling

- **Existing file uses non-`Should` naming throughout:** refactor the touched test function into canonical subtests; do not add another legacy-shaped case or rewrite unrelated suites.
- **The convention checker returns a false positive:** prove the syntax is valid against the canonical reference and record the narrow exception; never use the heuristic to waive a real rule.
- **`t.Setenv` used inside a helper that callers cannot inspect:** read the helper transitively. If env mutation occurs anywhere in the call graph, the entire test stays serial.
- **Race-enabled tests touching cgo:** use the repository's race-enabled command path, which forces `CGO_ENABLED=1`; do not trust ambient env.

More from compozy/agh

SkillDescription
agent-exploration>-
aghAGH runtime and contribution guide. Use for sessions, agents, native tools, skills, memory, network, tasks, capabilities, bundles, QA, docs, and repo work. Do not use for unrelated projects.
agh-cleanup-failure-paths>-
agh-code-guidelines>-
agh-contract-codegen-coshipContract co-ship for AGH wire changes. Use when editing public DTOs, OpenAPI, JSON-RPC extension shapes, generated clients, or handler request/response semantics. Do not use for internal Go refactors or test-only changes that leave the wire contract unchanged.
agh-data-boundariesData-boundary audit for AGH route loaders, TanStack Query caches, paginated catalogs, filters, ordering, totals, live streams, workspace-scoped reads, and their backend APIs. Use when adding, changing, or debugging those paths. Don't use for presentational-only UI or backend work with no public read-model impact.
agh-designAGH visual-design authority for production UI, static artifacts, prototypes, and reviews. Use when creating or reviewing an AGH surface or changing tokens, typography, spacing, depth, icons, or motion. Do not use for capture-only verification; use agh-ui-screenshot.
agh-qa-bootstrapBootstraps isolated AGH QA labs and emits the canonical manifest for downstream QA. Use when local QA needs daemon, workspace, provider, or playbook setup. Do not use for unit tests, planning-only work, or browser-only checks.
agh-schema-migrationAuthors append-only Goose SQL migrations for AGH SQLite streams and keeps declarative schema sources, atlas.sum, Atlas checks, sqlc output, and migration tests synchronized. Use for SQLite table, column, index, constraint, trigger, or seed-data changes under internal/store or internal/memory. Do not use for in-memory structures, derived Markdown memory, or non-SQLite caches.
agh-ui-screenshotScreenshot capture for deterministic PNG evidence and visual-contract bundles for AGH Storybook stories and local UI URLs. Use for visual audits, regression diffs, and design-parity checks. Do not use for interactive E2E flows, remote authenticated sites, or Storybook test execution.