Internal sub-skill. Loads test pattern learnings for the current repo and scans local test files to return structured test context used by write and cleanup test skills. Use when called by write-unit-tests, write-e2e-tests, cleanup-unit-tests, or cleanup-e2e-tests.
This is an internal sub-skill called by write-unit-tests, write-e2e-tests, cleanup-unit-tests, and cleanup-e2e-tests. It is not invoked directly by users.
Arguments: $ARGUMENTS (optional: path to scope the context)
Load stored test pattern learnings for the current repo and augment them with a live scan of nearby test files. Return a structured context block that the calling skill uses to write or fix tests in the correct style.
# Get repo name from git remote
git remote get-url origin 2>/dev/null | sed 's/.*\///' | sed 's/\.git//'
# Fallback: read name from package.json at root
Load test pattern learnings from the Obsidian vault using MCP search:
# Search for test pattern notes
mcp__obsidian__search-vault: vault="obsidian-vault", query="tag:topic/testing", path="repo-learnings/{repo-name}"
Read any notes returned (e2e-patterns.md, unit-patterns.md). Then search for test-related gotchas:
mcp__obsidian__search-vault: vault="obsidian-vault", query="tag:topic/gotcha", path="repo-learnings/{repo-name}/gotchas"
If test-traps.md is in the results, read it.
Fallback: If the vault search returns 0 results (vault not configured or repo not yet in vault):
Read ~/.claude/repo-learnings/{repo-name}/test-patterns.md
If that also does not exist, output a warning:
⚠ No test learnings found for this repo. Run /learn-repo first for better results.
Proceeding with live scan only.
If a path argument is provided, scan test files near that path. Otherwise scan the closest __tests__, test/, or *.test.ts / *.spec.ts files relative to the current working directory.
Capture and summarize:
*.test.ts, *.spec.ts, co-located vs __tests__/)Output a structured markdown block:
## Test Context for {repo-name}
### File Conventions
[naming, placement]
### Mock Patterns
[how stores, APIs, routers are mocked — with code examples from actual files]
### Factory Patterns
[how test data is built — with examples]
### Assertion Style
[async patterns, common matchers]
### E2E Conventions (if applicable)
[intercept patterns, page objects, wait strategy]
### Known Gotchas
[from test-patterns.md — things that have burned people before]
REPO=$(git remote get-url origin 2>/dev/null | sed 's/.*\///' | sed 's/\.git//')
BRANCH=$(git branch --show-current 2>/dev/null | sed 's/\//-/g')
TS=$(date +%Y%m%d-%H%M%S)-$$
mkdir -p ~/.claude/skill-output/$REPO/$BRANCH
Write this context block to ~/.claude/skill-output/$REPO/$BRANCH/test-context-$TS.md. Echo the full output path so the calling skill can read the exact file rather than guessing.