skills/specops-ambiguity-audit/SKILL.md
Audit a SpecOps analysis specification for ambiguities that would force an implementer to make undocumented judgment calls, then resolve them by spawning parallel subagents to research the legacy source code and patching the spec with concrete answers. Use this skill whenever the user mentions auditing, hardening, reviewing, or finding gaps in an analysis spec, an analysis.md file, a spec document, a SpecOps spec, or any specification derived from legacy code. Also trigger when the user asks to find unclear statements, vague behaviors, judgment calls, underspecified behavior, or implementation gaps in a spec, even if they don't use the word "ambiguity" explicitly. Trigger before generating code from a spec, after a spec-driven implementation drifted from expected behavior, or as a pre-verification pass before marking a spec verified.
npx skillsauth add ryan-mahoney/ryan-llm-skills specops-ambiguity-auditInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
A SpecOps analysis spec describes what legacy code does. Different implementers reading the same prose can make different judgment calls — the spec is "ambiguous" wherever it leaves room for reasonable people to disagree about intended behavior. Those gaps become bugs in the reimplementation.
This skill performs a two-phase audit on a single analysis file:
The output is a hardened spec: every behavior either documented concretely, or explicitly flagged as truly indeterminate from the source (and therefore needing a domain expert).
Confirm with the user before starting:
docs/specs/analysis/core/orchestrator.md).docs/specops/analysis-orchestration.md). If the spec doesn't list them, ask.<analysis-name>.ambiguities.md next to the spec.If the user names the spec but not the source files, look in the spec's first few sections (Purpose, Dependencies, Integration Points) and at any project-level orchestration doc for the source file list before asking.
Read the analysis file end-to-end. For each section, scan for the categories below. The unifying test is:
"If two implementers read this and built it independently, could they produce different behavior?"
If yes, it's ambiguous.
Vague quantifiers and qualifiers
Underspecified behavior
Missing defaults and thresholds
Implicit conditionals
Type and shape ambiguity
Concurrency and ordering gaps
Side-effect gaps
Internal contradictions
The spec's own Open Questions
Write the ambiguity list to <analysis-name>.ambiguities.md next to the spec. Use this format:
# Ambiguity Audit: <spec name>
- **Spec:** <full path>
- **Audited:** <date>
- **Source files referenced:** <list>
## Ambiguities
### A1
- **Section:** 4. Behavioral Contracts
- **Quote:** "Retries on transient failures with appropriate backoff."
- **Category:** Underspecified behavior + Missing thresholds
- **Question:** What classifies as "transient"? How many retry attempts? What backoff strategy and base interval?
- **Source files to investigate:** `src/core/retry.js`, `src/core/task-runner.js`
### A2
- **Section:** 3. Data Models & Structures — Status object
- **Quote:** "The status field holds the current lifecycle state."
- **Category:** Type ambiguity (enumeration not listed)
- **Question:** What are the valid values for the status field? Is there a defined transition graph?
- **Source files to investigate:** `src/config/statuses.js`, `src/core/status-writer.js`
### A3
...
The audit runs end-to-end without stopping for confirmation. Phase 1 produces the list; Phase 2 starts immediately. The user reviews the resulting report asynchronously — they don't need to be present while the audit runs. (If a user explicitly asks for an interactive run, you can pause here, but it's not the default.)
For each confirmed ambiguity, spawn a subagent in the same turn to research the source code. Don't run them serially — launch them all together.
Copy this template, fill in the placeholders, and pass it to each subagent:
You are researching a single ambiguity in a SpecOps analysis spec by reading the legacy source code that the spec describes. Your answer will be inserted directly into the spec, so be precise.
# The spec being audited
Path: <full path to analysis file>
(Read it first to understand context, then focus on the specific section below.)
# The ambiguous statement
- Section: <section name>
- Quote: "<exact quote from spec>"
- Category: <category>
- Question: <specific question to answer>
# Source files
Read these files completely:
<list of source file paths>
You may also read files imported by these or referenced from the spec if needed to answer the question. Do not read unrelated files.
# Your task
1. Read the listed source files completely (not just grep — full read).
2. Find the code that implements the behavior in question.
3. Determine the concrete answer — exact values, exact ordering, exact conditions, exact types, exact error categories.
4. Quote the relevant lines of source code as evidence.
5. **Most questions are answerable from source.** Before giving up, follow imports transitively, read related files, and trace call chains. Only mark `still_ambiguous: true` if the answer genuinely lives outside this codebase.
6. If you must defer, classify why with one of these specific causes:
- `closed_source_dependency` — behavior is delegated to a third-party library not in this repo
- `caller_supplied_config` — behavior depends on a value passed in by callers, not defaulted here
- `runtime_environment` — behavior depends on env vars, OS, file system layout the source doesn't document
- `unstated_policy` — the source contains an apparent contradiction or magic value that encodes a policy decision with no documented rationale
# Output format
Return a JSON object only, no commentary:
{
"ambiguity_id": "<the ID like A1>",
"answer": "<concrete prose answer suitable for inserting into the spec, implementation-language-agnostic>",
"spec_patch": {
"section": "<which section of the spec to update>",
"before": "<the original ambiguous quote>",
"after": "<the proposed replacement prose>"
},
"evidence": [
{"file": "<path>", "lines": "<line range>", "excerpt": "<relevant code>"}
],
"still_ambiguous": <true | false>,
"defer_reason": "<one of: closed_source_dependency, caller_supplied_config, runtime_environment, unstated_policy — only if still_ambiguous is true>",
"investigated": "<brief description of files read and call chains traced — only if still_ambiguous is true>",
"blocker": "<the specific external thing that prevents resolution — only if still_ambiguous is true>",
"suggested_resolver": "<who or what can resolve this — only if still_ambiguous is true>",
"suggested_next_action": "<concrete next step — only if still_ambiguous is true>"
}
If the host environment has no subagent capability (e.g., a vanilla chat with no Task tool), fall back to processing each ambiguity serially in the main loop, but keep the same prompt structure and output format. Note this in the audit log.
When all subagents return:
Sort results into resolved and deferred. Most subagents will return a concrete answer — code is rarely truly ambiguous when you have the source. The exceptions are real but uncommon, and they all have specific causes:
Items where still_ambiguous: true are deferred, not blocked. The audit continues. The deferred items get logged with full context (see step 4) so a human can pick them up out-of-band.
Apply the spec patches. For each resolved ambiguity, replace the original ambiguous quote with the after prose from the subagent. Preserve the spec's existing structure and voice — don't rewrite whole sections, just refine the specific sentences. Keep the spec implementation-language-agnostic: describe behavior, not code syntax.
Anchor evidence in the patch. Where a resolution came from specific source, the patched prose should reference it briefly — e.g., "As defined in src/core/retry.js, the retry policy uses exponential backoff starting at 100ms with a maximum of three attempts." This makes the next audit cheaper and gives reviewers a paper trail.
Update Section 11 (Open Questions & Ambiguities) with rich context. For each deferred item, write an entry with enough information that someone picking it up later can act without re-running the audit. Use this format:
### OQ-<id>: <short title>
- **Spec section affected:** <e.g., 4. Behavioral Contracts>
- **Original quote:** "<the ambiguous statement from the spec>"
- **Question:** <the specific question that needs answering>
- **Why deferred:** <one of: closed-source dependency / caller-supplied config / runtime environment / unstated policy decision>
- **What was investigated:** <files the subagent read, functions it traced>
- **Specific blocker:** <e.g., "Behavior is delegated to `chokidar.watch()`, whose debounce semantics are not specified in this repo">
- **Who can resolve this:** <e.g., "Anyone with chokidar API knowledge" / "The team that owns the calling code" / "Domain expert on retry policy">
- **Suggested next action:** <e.g., "Check chokidar docs for `awaitWriteFinish` defaults" / "Ask <team> what timeout they pass" / "Decide policy and document">
Also remove pre-existing open questions that this audit resolved. If Section 11 didn't exist (older specs), add it.
Append an audit log at the end of the analysis file:
---
## Audit History
### <YYYY-MM-DD> — Ambiguity audit
- Ambiguities identified: <count>
- Resolved with concrete answers: <count>
- Deferred (need out-of-band resolution): <count>
- Source files re-examined: <list>
- Audit report: `<analysis-name>.ambiguities.md`
- Deferred items: see Section 11 (Open Questions) for OQ-<id> entries
Save the ambiguity working file alongside the spec for traceability. It records what was found, what each subagent answered, and the evidence — useful for reviewers and for diffing across audit passes.
Summarize for the user. Show:
still_ambiguous: true as a real but uncommon outcome with specific causes (closed-source deps, caller-supplied config, runtime environment, unstated policy). If a subagent reports it for a different reason, that's a signal the subagent didn't dig hard enough — consider re-running it with more aggressive instructions to read transitively imported files.<spec>.ambiguities.md as a separate persistent artifact. Future audits diff against it.User: "Audit docs/specs/analysis/core/orchestrator.md for ambiguity."
src/core/orchestrator.js plus anything obviously relevant).docs/specs/analysis/core/orchestrator.ambiguities.md with, say, 14 numbered ambiguities.still_ambiguous — the file watcher's debounce behavior is delegated to chokidar, a third-party dependency whose internals aren't in this repo.orchestrator.md: 13 in-place clarifications across sections 2, 3, 4, and 7. The 1 deferred item goes into Section 11 as OQ-1 with full context: what was investigated, why it's deferred (closed-source dep), who can resolve it (anyone with chokidar API knowledge), and the suggested next action (check the chokidar docs for awaitWriteFinish defaults). Append the audit log.documentation
This skill should be used when the user asks to "write a spec", "create a spec", "spec this out", "plan this feature", or "write an implementation plan" for a feature or change. Creates a structured implementation spec in .specs/<slug>/spec.md and mirrors it to GitHub only when the current repository is hosted on GitHub.
data-ai
This skill should be used when the user asks to "execute the spec", "run the plan", "implement the spec", "implement the issue", "run all steps", or "run spec". Implements all steps from .specs/<slug>/spec.md, using a subagent per step when the harness supports subagents.
testing
This skill should be used when the user asks to "review a spec", "review an issue", "check the plan", "review the implementation plan", "find gaps in the spec", or "review spec". Reviews .specs/<slug>/spec.md for gaps and viability, edits it when needed, and mirrors changes to GitHub only when a GitHub mirror exists.
development
This skill should be used when the user asks to "remediate the audit findings", "fix the spec violations", "close the audit findings", "fix conformance violations", or "spec remediate". Reads a spec-audit report, drives one smart subagent per VIOLATION to converge the code back to the frozen spec, and re-audits until clean. Edits production code; never rewrites the spec.