Best-Practices Audit
Task
Validate a target — a file, directory, or freeform topic — against current
external best practices, vendor documentation, and practitioner discussion.
Produce a cited, evidence-grounded comparison report.
This is the research-grounded validation pattern from #929: it institutionalizes
the practice of validating against fresh internet sources rather than the
model's training-cutoff priors. The improvement is real only when retrieved
sources have good signal, so the skill enforces citation guardrails and
confidence honesty rather than fabricating breadth.
Parameters
Positional
<target> (required): file path, directory, freeform topic, or issue ref
Focus / Scope
--focus <area>: security | performance | accessibility | licensing | api-design | testing | docs | ops | compliance | … (open vocabulary)
--framework <name>: bias toward a named stack (React, Kubernetes, FastAPI, …)
--standard <name>: align to a named standard (OWASP, SOC2, WCAG 2.2, NIST 800-53, …)
Research Budget
--recency <window>: default 18 months. Tighten for fast-moving domains, widen for compliance/legal
--depth quick|standard|deep: research effort budget (default standard)
--sources <list>: restrict to: vendor-docs, standards-bodies, practitioner-blogs, conference-talks, academic, github-discussions
--exclude <list>: e.g. exclude SEO-spam domains
--cite-threshold <N>: minimum distinct sources before a finding is reported (default 2)
Reporting
--dissent: actively surface practitioner disagreement, not just consensus
--validate: re-validate existing claims in the target rather than generating new ones
--output <path>: where to write the report (CLI handler computes the default)
Pipeline
The CLI handler at src/cli/handlers/best-practices-audit.ts parses flags
and computes the output path; this skill receives a fully-formed prompt and
runs the research pipeline.
Step 1: Scope
- Resolve the target.
- Path exists? Read the file/directory and enumerate distinct claims or
decisions stated in it (architecture choices, dependency selections,
pattern usages).
- Path doesn't exist? Treat as freeform topic — the entire audit is
about the topic itself.
- Inventory claims. Each claim becomes a unit of evaluation downstream:
"we use Tower middleware for retries", "Postgres handles >500K users at
the budgeted instance size", "WCAG 2.2 AA is required". For freeform
topics, the claim is implicitly "what does current practice say about
this topic?".
- Apply guidance.
--focus and --framework filter which claims are
in scope. --validate switches to claim re-verification mode (no
generative findings).
Step 1.5: Contributor Discovery (per ADR-023)
Before fan-out, discover any installed framework's kind: research contributors
that match the project. The discovery convention is described in ADR-023; the
runtime authority is src/contributors/discover.ts and the discovery loop
matches the algorithm there.
Read .aiwg/frameworks/registry.json. For each registered framework id,
check for <source-path>/research/contributor.md under
agentic/code/frameworks/, agentic/code/addons/, or agentic/code/extensions/
(first match wins per ADR-023 §Layout).
Walk .aiwg/contributors/research/*.md for project-local research
contributors.
For each candidate, parse YAML frontmatter and validate against the
kind: research schema (published at
agentic/code/frameworks/research-complete/skills/best-practices-audit/contributor.schema.json).
Run each contributor's detect.glob against the project root. Skip contributors
whose detection produces fewer than detect.minCount matches — installed
but unused frameworks do not pollute the audit.
For each in-use research contributor, fold its frontmatter into the
research plan:
focus_areas — intersect with the user's --focus flag if present.
If --focus is omitted, use the contributor's full focus list. Multiple
contributors' areas merge with union semantics.
sources.preferred and sources.exclude — add to the audit's
allow / block lists. The user's --sources and --exclude flags take
precedence; contributor preferences fill in defaults the user did not
specify.
recency_default_months — used as the per-contributor default
when --recency is not set. When multiple contributors disagree, pick
the shorter window (more conservative — fresher sources are a
stronger guarantee than older sources).
Stamp origin: <framework-id> on every finding sourced through that
contributor's expanded plan. Findings sourced from the generic path
(no contributor) get origin: generic. Project-local research
contributors stamp origin: project-local.
No regression when no contributors are present. If discovery returns
zero in-use contributors, fall through to the bare generic path described
in #943 — same behavior as before this issue's wiring landed.
When validate-metadata is available, the schema enforces correctness at
deploy time. At audit time, this step trusts validated frontmatter; a
contributor that fails parsing or validation is logged and skipped per
ADR-023 §Failure mode.
Step 2: Research Fan-Out
Dispatch research per claim/focus area using the AIWG research-complete
agents, expanded by any contributor configurations from Step 1.5.
Reuse existing capabilities — do not implement parallel research
machinery.
Available capabilities (load-on-demand from research-complete):
find-sources — discover candidate sources via vendor docs, standards
bodies, practitioner channels
research-acquire — fetch and process candidate documents
research-quality — apply GRADE quality scoring
citation-guard — block fabricated citations
research-query — query the local research corpus when one is present
If media-curator and the marketing kit are also installed, dispatch them
for web-scraping cross-references where appropriate (e.g. practitioner
blog comparisons).
Concurrency rule per AIWG context-budget: the agent should issue parallel
research tasks where independent (different focus areas, different claims),
but not multiplex the same claim into N redundant subagents.
Step 3: Source Quality Gating
For each candidate source returned by research:
- Apply
--sources allow-list and --exclude block-list.
- Run
citation-guard to verify the source is real and retrievable
(URL reachable, content present at the cited location, not a 404 or
redirect to unrelated content).
- Apply GRADE methodology via
research-quality — score each source as
high / moderate / low.
- Apply
--recency window — sources older than the window are demoted
one quality level.
- Drop sources that fail any gate. Do not "rescue" weak sources by
relaxing thresholds without explicit
--guidance to do so.
Step 4: Comparison
For each claim:
- Aggregate the surviving sources.
- If fewer than
--cite-threshold distinct sources support the claim's
alignment-or-divergence assessment, downgrade the finding to "weak
signal" rather than dropping it silently. Users need to see when
the corpus didn't support a strong conclusion — that is itself a
finding.
- Determine alignment: ALIGNED / PARTIAL / DIVERGES / CONTESTED.
- With
--dissent, also extract dissenting voices: who argues the other
way, where, and on what grounds. Surface these as a labeled section,
not a footnote.
Step 5: Report
Write to the output path computed by the CLI handler. Structure per #929 §5:
# Best-Practices Audit: <target>
**Generated**: YYYY-MM-DD
**Focus**: <flags or 'all'>
**Depth**: <flag>
**Cite threshold**: <N>
## Executive Summary
<2–4 sentences: what's aligned, what's misaligned, overall confidence>
## Findings
### Finding 1: <claim or decision under review>
- **Current state in project**: <quote/paraphrase with file:line if available>
- **Current industry practice**: <summary>
- **Alignment**: ALIGNED | PARTIAL | DIVERGES | CONTESTED | WEAK SIGNAL
- **Confidence**: high | moderate | low
- **Evidence**:
- [S1] <source title> — <vendor/standards body/blog>, <date>, <url>
- [S2] ...
- **Recommendation**: <specific change or 'keep as-is, well-justified by
current practice'>
(repeat per claim)
## Dissenting Views / Open Debates
<where practitioners disagree and why — empty section is acceptable when
nothing surfaced; do not invent dissent>
## Sources
Full bibliography with retrieval dates. Every source cited above must
appear here with full provenance. No citation appears in Findings without
appearing in Sources.
## Methodology Notes
- Research depth: <quick|standard|deep>
- Recency window: <window>
- Sources excluded: <list, including domains blocked by --exclude>
- Sources unavailable: <list, with reason — e.g. paywalled, 404>
Anti-Hallucination Guardrails (Hard Requirements)
These are non-negotiable. Failure to meet any of these breaks the
audit's core value proposition.
- No fabricated citations, DOIs, URLs, or quotes. Every cited URL must
be the result of a retrieval that returned content at that URL.
citation-guard
enforces this; if citation-guard is unavailable, the audit must
surface that fact in Methodology Notes and downgrade overall confidence.
- Cite-threshold is enforced, not advisory. A finding below threshold is
downgraded to WEAK SIGNAL or dropped — never reported as if the threshold
were met.
- Conflicting sources surface as labeled disagreement. If sources A and B
disagree, the report says so explicitly. The audit does not silently
pick one and pretend consensus.
- Sparse signal is reported honestly. When the corpus is thin or weak,
the report says so and downgrades confidence. The audit does not
fill the void with the model's training-data priors.
- Training-data-only claims are marked. Any background context the
audit relies on without a citation is labeled
(no external citation verified) so the reader knows what's grounded vs what's not.
--validate mode never generates new findings. It only re-checks
claims already present in the target. If a claim's supporting source
is no longer reachable or has changed, the audit reports that the
claim is now unverified, not that there's a new claim to make.
Out of Scope (deferred per #929)
- Cache layer for repeated audits — see deferred tracker #946 (caching applies
to contributor discovery; research caching is a separate concern but not
in scope for this skill)
- Auto-ingest into the knowledge-base framework — defer until best-practices-audit
has been used in anger and we can see whether ingestion is valuable
(#929 open question 4)
- (Contributor-driven prompt expansion now wired in — see Step 1.5 above. The
earlier "deferred" note from #943 is resolved by #944.)
References
- @.aiwg/architecture/decisions/ADR-023-contributor-discovery-convention.md — the contributor convention #944 will wire into this skill
- @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/find-sources/SKILL.md — source discovery
- @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/research-acquire/SKILL.md — source retrieval and processing
- @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/research-quality/SKILL.md — GRADE methodology
- @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/citation-guard/SKILL.md — fabricated-citation detection
- @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/research-query/SKILL.md — local corpus queries
- @$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/research-before-decision.md — research-first rule the audit's pipeline implements
- @$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/context-budget.md — parallel subagent limits applied during research fan-out
1---2namespace: aiwg3name: best-practices-audit4platforms: [all]5description: Research-grounded validation of a target (file, directory, or topic) against external best practices and vendor docs. Produces a cited, evidence-grounded comparison.6commandHint:7 argumentHint: "<target> [--focus <area>] [--standard <name>] [--depth quick|standard|deep] [--cite-threshold <N>] [--dissent] [--validate] [--output <path>]"8 allowedTools: Read, Write, Glob, Grep, Bash, WebFetch, WebSearch9 model: opus10 category: research-validation11 modelRole: reasoning12 modelTier: premium13 modelRationale: External evidence synthesis can change high-impact technical policy.14---1516# Best-Practices Audit1718## Task1920Validate a target — a file, directory, or freeform topic — against current21external best practices, vendor documentation, and practitioner discussion.22Produce a cited, evidence-grounded comparison report.2324This is the research-grounded validation pattern from #929: it institutionalizes25the practice of validating against fresh internet sources rather than the26model's training-cutoff priors. The improvement is real **only when retrieved27sources have good signal**, so the skill enforces citation guardrails and28confidence honesty rather than fabricating breadth.2930## Parameters3132### Positional33- **`<target>`** (required): file path, directory, freeform topic, or issue ref3435### Focus / Scope36- **`--focus <area>`**: security | performance | accessibility | licensing | api-design | testing | docs | ops | compliance | … (open vocabulary)37- **`--framework <name>`**: bias toward a named stack (React, Kubernetes, FastAPI, …)38- **`--standard <name>`**: align to a named standard (OWASP, SOC2, WCAG 2.2, NIST 800-53, …)3940### Research Budget41- **`--recency <window>`**: default 18 months. Tighten for fast-moving domains, widen for compliance/legal42- **`--depth quick|standard|deep`**: research effort budget (default `standard`)43- **`--sources <list>`**: restrict to: vendor-docs, standards-bodies, practitioner-blogs, conference-talks, academic, github-discussions44- **`--exclude <list>`**: e.g. exclude SEO-spam domains45- **`--cite-threshold <N>`**: minimum distinct sources before a finding is reported (default `2`)4647### Reporting48- **`--dissent`**: actively surface practitioner disagreement, not just consensus49- **`--validate`**: re-validate existing claims in the target rather than generating new ones50- **`--output <path>`**: where to write the report (CLI handler computes the default)5152## Pipeline5354The CLI handler at `src/cli/handlers/best-practices-audit.ts` parses flags55and computes the output path; this skill receives a fully-formed prompt and56runs the research pipeline.5758### Step 1: Scope59601. **Resolve the target.**61 - Path exists? Read the file/directory and enumerate distinct claims or62 decisions stated in it (architecture choices, dependency selections,63 pattern usages).64 - Path doesn't exist? Treat as freeform topic — the entire audit is65 about the topic itself.662. **Inventory claims.** Each claim becomes a unit of evaluation downstream:67 "we use Tower middleware for retries", "Postgres handles >500K users at68 the budgeted instance size", "WCAG 2.2 AA is required". For freeform69 topics, the claim is implicitly "what does current practice say about70 this topic?".713. **Apply guidance.** `--focus` and `--framework` filter which claims are72 in scope. `--validate` switches to claim re-verification mode (no73 generative findings).7475### Step 1.5: Contributor Discovery (per ADR-023)7677Before fan-out, discover any installed framework's `kind: research` contributors78that match the project. The discovery convention is described in ADR-023; the79runtime authority is `src/contributors/discover.ts` and the discovery loop80matches the algorithm there.81821. Read `.aiwg/frameworks/registry.json`. For each registered framework id,83 check for `<source-path>/research/contributor.md` under84 `agentic/code/frameworks/`, `agentic/code/addons/`, or `agentic/code/extensions/`85 (first match wins per ADR-023 §Layout).862. Walk `.aiwg/contributors/research/*.md` for project-local research87 contributors.883. For each candidate, parse YAML frontmatter and validate against the89 `kind: research` schema (published at90 `agentic/code/frameworks/research-complete/skills/best-practices-audit/contributor.schema.json`).914. Run each contributor's `detect.glob` against the project root. Skip contributors92 whose detection produces fewer than `detect.minCount` matches — installed93 but unused frameworks do not pollute the audit.945. For each in-use research contributor, fold its frontmatter into the95 research plan:9697 - **`focus_areas`** — intersect with the user's `--focus` flag if present.98 If `--focus` is omitted, use the contributor's full focus list. Multiple99 contributors' areas merge with union semantics.100 - **`sources.preferred`** and **`sources.exclude`** — add to the audit's101 allow / block lists. The user's `--sources` and `--exclude` flags take102 precedence; contributor preferences fill in defaults the user did not103 specify.104 - **`recency_default_months`** — used as the per-contributor default105 when `--recency` is not set. When multiple contributors disagree, pick106 the **shorter** window (more conservative — fresher sources are a107 stronger guarantee than older sources).1086. Stamp `origin: <framework-id>` on every finding sourced through that109 contributor's expanded plan. Findings sourced from the generic path110 (no contributor) get `origin: generic`. Project-local research111 contributors stamp `origin: project-local`.1127. **No regression when no contributors are present.** If discovery returns113 zero in-use contributors, fall through to the bare generic path described114 in #943 — same behavior as before this issue's wiring landed.115116When validate-metadata is available, the schema enforces correctness at117deploy time. At audit time, this step trusts validated frontmatter; a118contributor that fails parsing or validation is logged and skipped per119ADR-023 §Failure mode.120121### Step 2: Research Fan-Out122123Dispatch research per claim/focus area using the AIWG research-complete124agents, expanded by any contributor configurations from Step 1.5.125**Reuse existing capabilities — do not implement parallel research126machinery.**127128Available capabilities (load-on-demand from research-complete):129- `find-sources` — discover candidate sources via vendor docs, standards130 bodies, practitioner channels131- `research-acquire` — fetch and process candidate documents132- `research-quality` — apply GRADE quality scoring133- `citation-guard` — block fabricated citations134- `research-query` — query the local research corpus when one is present135136If `media-curator` and the marketing kit are also installed, dispatch them137for web-scraping cross-references where appropriate (e.g. practitioner138blog comparisons).139140**Concurrency rule per AIWG context-budget**: the agent should issue parallel141research tasks where independent (different focus areas, different claims),142but not multiplex the same claim into N redundant subagents.143144### Step 3: Source Quality Gating145146For each candidate source returned by research:1471481. Apply `--sources` allow-list and `--exclude` block-list.1492. Run `citation-guard` to verify the source is real and retrievable150 (URL reachable, content present at the cited location, not a 404 or151 redirect to unrelated content).1523. Apply GRADE methodology via `research-quality` — score each source as153 high / moderate / low.1544. Apply `--recency` window — sources older than the window are demoted155 one quality level.1565. Drop sources that fail any gate. Do not "rescue" weak sources by157 relaxing thresholds without explicit `--guidance` to do so.158159### Step 4: Comparison160161For each claim:1621631. Aggregate the surviving sources.1642. If fewer than `--cite-threshold` distinct sources support the claim's165 alignment-or-divergence assessment, **downgrade the finding to "weak166 signal" rather than dropping it silently**. Users need to see when167 the corpus didn't support a strong conclusion — that is itself a168 finding.1693. Determine alignment: ALIGNED / PARTIAL / DIVERGES / CONTESTED.1704. With `--dissent`, also extract dissenting voices: who argues the other171 way, where, and on what grounds. Surface these as a labeled section,172 not a footnote.173174### Step 5: Report175176Write to the output path computed by the CLI handler. Structure per #929 §5:177178```markdown179# Best-Practices Audit: <target>180181**Generated**: YYYY-MM-DD182**Focus**: <flags or 'all'>183**Depth**: <flag>184**Cite threshold**: <N>185186## Executive Summary187188<2–4 sentences: what's aligned, what's misaligned, overall confidence>189190## Findings191192### Finding 1: <claim or decision under review>193194- **Current state in project**: <quote/paraphrase with file:line if available>195- **Current industry practice**: <summary>196- **Alignment**: ALIGNED | PARTIAL | DIVERGES | CONTESTED | WEAK SIGNAL197- **Confidence**: high | moderate | low198- **Evidence**:199 - [S1] <source title> — <vendor/standards body/blog>, <date>, <url>200 - [S2] ...201- **Recommendation**: <specific change or 'keep as-is, well-justified by202 current practice'>203204(repeat per claim)205206## Dissenting Views / Open Debates207208<where practitioners disagree and why — empty section is acceptable when209nothing surfaced; do not invent dissent>210211## Sources212213Full bibliography with retrieval dates. Every source cited above must214appear here with full provenance. No citation appears in Findings without215appearing in Sources.216217## Methodology Notes218219- Research depth: <quick|standard|deep>220- Recency window: <window>221- Sources excluded: <list, including domains blocked by --exclude>222- Sources unavailable: <list, with reason — e.g. paywalled, 404>223```224225## Anti-Hallucination Guardrails (Hard Requirements)226227These are **non-negotiable**. Failure to meet any of these breaks the228audit's core value proposition.2292301. **No fabricated citations, DOIs, URLs, or quotes.** Every cited URL must231 be the result of a retrieval that returned content at that URL. `citation-guard`232 enforces this; if `citation-guard` is unavailable, the audit must233 surface that fact in Methodology Notes and downgrade overall confidence.2342. **Cite-threshold is enforced, not advisory.** A finding below threshold is235 downgraded to WEAK SIGNAL or dropped — never reported as if the threshold236 were met.2373. **Conflicting sources surface as labeled disagreement.** If sources A and B238 disagree, the report says so explicitly. The audit does not silently239 pick one and pretend consensus.2404. **Sparse signal is reported honestly.** When the corpus is thin or weak,241 the report says so and downgrades confidence. The audit does **not**242 fill the void with the model's training-data priors.2435. **Training-data-only claims are marked.** Any background context the244 audit relies on without a citation is labeled `(no external citation245 verified)` so the reader knows what's grounded vs what's not.2466. **`--validate` mode never generates new findings.** It only re-checks247 claims already present in the target. If a claim's supporting source248 is no longer reachable or has changed, the audit reports that the249 claim is now unverified, not that there's a new claim to make.250251## Out of Scope (deferred per #929)252253- Cache layer for repeated audits — see deferred tracker #946 (caching applies254 to contributor discovery; research caching is a separate concern but not255 in scope for this skill)256- Auto-ingest into the knowledge-base framework — defer until best-practices-audit257 has been used in anger and we can see whether ingestion is valuable258 (#929 open question 4)259- (Contributor-driven prompt expansion now wired in — see Step 1.5 above. The260 earlier "deferred" note from #943 is resolved by #944.)261262## References263264- @.aiwg/architecture/decisions/ADR-023-contributor-discovery-convention.md — the contributor convention #944 will wire into this skill265- @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/find-sources/SKILL.md — source discovery266- @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/research-acquire/SKILL.md — source retrieval and processing267- @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/research-quality/SKILL.md — GRADE methodology268- @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/citation-guard/SKILL.md — fabricated-citation detection269- @$AIWG_ROOT/agentic/code/frameworks/research-complete/skills/research-query/SKILL.md — local corpus queries270- @$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/research-before-decision.md — research-first rule the audit's pipeline implements271- @$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/context-budget.md — parallel subagent limits applied during research fan-out