Goal backward verification

From oimiragieo/agent-studio · View interactive version

Goal backward verification is an AI agent skill from the GitHub repository oimiragieo/agent-studio. Verify that task outputs actually achieve stated goals through 4 progressive levels of verification

How to use this skill

Skill file

Goal-Backward Verification

Verify that task outputs actually achieve stated goals through 4 progressive levels of verification. Works backward from the goal to verify each artifact exists, is substantive, is wired into the system, and passes functional tests.

When to Invoke

Skill({ skill: 'goal-backward-verification' });

Invoke when:

Verification Levels

Level 1: Exists

Verify the expected output artifact is present on disk.

# Check file existence
test -f <expected_path> && echo "PASS: File exists" || echo "FAIL: File missing"

Pass: File exists at expected path.

Fail: File missing — task did not produce expected output.

Level 2: Substantive

Verify the file contains real content, not a stub or placeholder.

Checks:

# Count substantive lines (non-empty, non-comment)
grep -cvE '^\s*(//|#|\*|$|TODO|PLACEHOLDER|FIXME|STUB)' <file>

Pass: File has substantive content (>10 real lines).

Fail: Stub detected — file exists but contains no real implementation.

Level 3: Wired

Verify the artifact is imported, referenced, or registered by the system.

Checks:

# Search for references to the artifact
grep -r "require.*<module-name>" .claude/ --include="*.cjs" --include="*.js" | grep -v node_modules | grep -v _archive

Pass: At least 1 external reference found.

Fail: Orphaned artifact — exists but nothing uses it.

Level 4: Functional

Verify the artifact passes its associated tests end-to-end.

Checks:

# Run associated tests
node --test tests/<path>/<artifact>.test.cjs

Pass: All tests pass (exit code 0).

Fail: Test failures detected — artifact may be broken.

Modes

Strict Mode (default for HIGH/EPIC complexity)

All 4 levels must pass. Any failure at any level blocks the verification.

Advisory Mode (default for LOW/MEDIUM complexity)

All 4 levels are checked, but failures produce warnings instead of blocking. Useful for incremental development where wiring may not be complete yet.

Set mode via environment variable:

GOAL_VERIFICATION_MODE=strict  # or advisory

Output Format

{
  "artifact": "path/to/file",
  "levels": {
    "exists": { "passed": true },
    "substantive": { "passed": true, "lines": 45 },
    "wired": { "passed": true, "references": ["path/to/importer.cjs"] },
    "functional": { "passed": false, "reason": "2 tests failed", "exitCode": 1 }
  },
  "verdict": "PARTIAL",
  "mode": "advisory",
  "passedLevels": 3,
  "totalLevels": 4
}

Verdict values:

Workflow

Step 1: Identify Artifacts

Read the task's acceptance criteria or plan file to identify expected output artifacts (files, schemas, skills, hooks).

Step 2: Run Verification Cascade

For each artifact, run Levels 1-4 in order. Stop early if Level 1 fails (no point checking substantiveness of a missing file).

Step 3: Produce Report

Generate structured JSON output with per-artifact, per-level results. Include the overall verdict.

Step 4: Log Results

In advisory mode, log warnings to session-gap-log for reflection-agent consumption. In strict mode, return FAIL verdict to block completion.

Anti-Patterns

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.