.agents/skills/oat-agent-instructions-analyze/SKILL.md
Run when you need to evaluate agent instruction file coverage, quality, and drift. Produces a severity-rated analysis artifact. Run before oat-agent-instructions-apply to identify what needs improvement.
npx skillsauth add tkstang/open-agent-toolkit oat-agent-instructions-analyzeInstall 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.
Scan, evaluate, and report on agent instruction file coverage, quality, and drift across all detected providers.
jq available in PATH (used by helper scripts).OAT MODE: Agent Instructions Analysis
Purpose: Evaluate instruction file quality and coverage, produce an actionable analysis artifact.
BLOCKED Activities:
ALLOWED Activities:
.oat/repo/analysis/..oat/tracking.json.oat-agent-instructions-analyze owns discovery, evaluation, evidence gathering, and recommendation shaping.
Its output now has two layers:
agent-instructions-<timestamp>.md)agent-instructions-<timestamp>.bundle/)The markdown artifact is for reviewers. The bundle is the generation contract that oat-agent-instructions-apply
should consume when it exists.
oat-agent-instructions-apply may verify that cited files still exist and may read those same cited
sources while generating output, but it must not invent unsupported conventions, create new recommendations,
or fill in missing evidence gaps on its own.
Print a phase banner once at start:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OAT ▸ AGENT INSTRUCTIONS ANALYSIS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Step indicators:
[1/10] Resolving providers + mode…[2/10] Discovering instruction files…[3/10] Discovering documentation surfaces…[4/10] Evaluating quality + validating existing rules…[5/10] Assessing directory coverage gaps…[6/10] Discovering file-type patterns…[7/10] Checking for drift…[8/10] Checking cross-format consistency…[9/10] Writing analysis artifact…[10/10] Updating tracking + summary…Resolve providers:
SCRIPT_DIR=".agents/skills/oat-agent-instructions-analyze/scripts"
TRACKING_SCRIPT=".oat/scripts/resolve-tracking.sh"
PROVIDERS=$(bash "$SCRIPT_DIR/resolve-providers.sh" --non-interactive)
# Or with explicit override:
# PROVIDERS=$(bash "$SCRIPT_DIR/resolve-providers.sh" --providers claude,cursor)
If running interactively (user invoked the skill directly), omit --non-interactive to allow the user to confirm or add providers.
Resolve analysis mode (delta vs full):
TRACKING=$(bash "$TRACKING_SCRIPT" read agentInstructions)
TRACKING is non-empty, extract commitHash from the JSON.git rev-parse --verify "$STORED_HASH^{commit}" 2>/dev/null
Delta mode scoping:
git diff --name-only "$STORED_HASH"..HEAD
Use the changed file list to limit coverage gap assessment (Step 5) and drift detection (Step 7) to affected directories. Quality evaluation (Step 4) always runs on ALL instruction files regardless of mode.
echo "$PROVIDERS" | bash "$SCRIPT_DIR/resolve-instruction-files.sh"
This outputs tab-separated provider\tpath lines. Parse into an inventory for evaluation.
If no instruction files are found at all (not even a root AGENTS.md), report this as a Critical finding and recommend creating one via oat-agent-instructions-apply.
Scan the repository for documentation surfaces that instruction files could reference. This inventory feeds into
quality evaluation (Criterion 14) and provides concrete link targets for link_only disclosure decisions.
Discovery sources (check all; none are required — this must work with or without OAT configuration):
1. OAT docs config (if available):
# Only if .oat/config.json exists
cat .oat/config.json 2>/dev/null | jq -r '.documentation // empty'
If present, extract root and index paths. Use these as the primary docs surface, but do not skip other sources.
2. Docs directories:
Scan for directories named docs/, doc/, and apps/*/docs/. For each found directory:
index.md filesindex.md contains a ## Contents section, parse the topic-to-path map (these follow the OAT docs index contract)# Example discovery
find . -maxdepth 3 -type d -name 'docs' -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/.oat/*' -not -path '*/dist/*'
3. READMEs:
Find README.md files at the root and in key subdirectories (packages, apps, modules, services).
READMEs are often the only documentation for a package and are valuable link targets for scoped instruction files.
find . -maxdepth 3 -name 'README.md' -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/dist/*'
4. Knowledge base (only if current):
Check if .oat/repo/knowledge/ exists and contains files. If so:
project-index.md frontmatter for oat_generated_at and oat_source_main_merge_base_shaKNOWLEDGE_SHA=$(grep 'oat_source_main_merge_base_sha' .oat/repo/knowledge/project-index.md 2>/dev/null | awk '{print $2}')
if [ -n "$KNOWLEDGE_SHA" ]; then
FILES_CHANGED=$(git diff --name-only "$KNOWLEDGE_SHA"..HEAD 2>/dev/null | wc -l)
GENERATED_AT=$(grep 'oat_generated_at' .oat/repo/knowledge/project-index.md | awk '{print $2}')
fi
stale in the inventory but do not recommend linking to stale knowledge filesarchitecture.md, conventions.md, stack.md, structure.md, testing.md, integrations.md, concerns.md5. Standalone documentation files:
Scan for common standalone docs:
ARCHITECTURE.md, DESIGN.md, CONTRIBUTING.md at repo rootADR/ or decisions/ directories (architectural decision records).github/*.md files (excluding templates like PULL_REQUEST_TEMPLATE.md)# Example discovery
ls ARCHITECTURE.md DESIGN.md CONTRIBUTING.md 2>/dev/null
find . -maxdepth 1 -type d \( -name 'ADR' -o -name 'decisions' \) 2>/dev/null
find .github -maxdepth 1 -name '*.md' -not -name 'PULL_REQUEST_TEMPLATE*' -not -name 'ISSUE_TEMPLATE*' 2>/dev/null
Output:
Build a Documentation Inventory for the analysis artifact. Each entry records:
| Field | Description |
| ------------ | --------------------------------------------------------------------------- |
| Type | docs-app, readme, knowledge, standalone |
| Path | Relative path from repo root |
| Topics/Scope | What the doc covers (e.g., "CLI usage", "architecture, conventions") |
| Current? | current, stale, or N/A (for non-versioned docs like READMEs) |
| Notes | Additional context (e.g., "OAT config root", "package-level", "thin index") |
This inventory is used by:
link_only.Link Targets field with docs from this inventory that are topically relevant to the directory scope. Prefer scope-specific docs over project-wide docs.For each discovered instruction file, evaluate against the quality checklist at references/quality-checklist.md.
Required context — read these bundled skill docs before evaluating:
These docs are bundled with this skill under references/docs/ and should be read from that location,
not from repo-root .agents/docs/.
references/docs/agent-instruction.md — full quality criteria and best practicesreferences/docs/rules-files.md — cross-provider rules file format referencereferences/docs/cursor-rules-files.md — Cursor-specific .mdc format reference (if cursor provider is active)Evidence standard:
.editorconfig, oxlint, oxfmt, ESLint, Prettier, Ruff, etc.),
package.json scripts, existing checked-in instruction files, repo documentation, and repeated codebase patterns
with exact file references.Documentation inventory integration:
When evaluating Criterion 12 (Progressive Disclosure) and Criterion 14 (Available Documentation Is Referenced), use the documentation inventory from Step 2 to:
link_only with the specific doc pathFor each file:
inline, link_only, omit, or ask_user.Provider-specific validation:
@AGENTS.md import if present, check for content duplication with AGENTS.md..claude/rules/*.md): Validate paths frontmatter if conditional..cursor/rules/*.mdc): Validate frontmatter fields (alwaysApply, globs, description)..github/instructions/*.instructions.md): Validate applyTo frontmatter..github/copilot-instructions.md): Verify it's a minimal pointer, not content duplication.Instruction load budget assessment:
When checking Criterion 4 (Size Within Budget), compute and record:
Use these scenarios in the artifact's load-budget section so reviewers can distinguish normal operating cost from repo-wide totals.
Existing instruction files are not pre-validated truth. For each existing glob-scoped rule:
At minimum, validate:
Record the outcome in the artifact's existing-rule validation section. Any discrepancy that would cause agents to follow the wrong pattern should be flagged as a High finding or higher.
Walk the directory tree and evaluate each directory against references/directory-assessment-criteria.md.
Before general coverage-gap analysis, assess provider baseline gaps for every active provider. These checks are mandatory even when the missing file does not appear in the discovered inventory.
Provider baseline examples:
AGENTS.md and the claude provider is active but the matching CLAUDE.md shim is missing, record an explicit recommendation to create CLAUDE.md with the canonical @AGENTS.md import. This applies to every directory with an AGENTS.md — root and nested alike (e.g., packages/cli/AGENTS.md → packages/cli/CLAUDE.md)..github/copilot-instructions.md is missing, record an explicit recommendation to create the minimal Copilot shim.AGENTS.md.Do not leave these as implied apply-time behavior. They must appear in the analysis artifact as explicit provider-baseline recommendations.
Chained recommendations for new AGENTS.md files:
When a coverage-gap recommendation proposes creating a new AGENTS.md in a subdirectory, also emit the corresponding provider-baseline recommendations for that directory in the same artifact. For example, if the analysis recommends creating packages/cli/AGENTS.md and the claude provider is active, it must also recommend creating packages/cli/CLAUDE.md with @AGENTS.md. Do not defer these to a follow-up analysis — they belong in the same artifact so oat-agent-instructions-apply can generate both files in one pass.
In delta mode: Only assess directories that contain files changed since the last tracked commit. Skip unchanged directories.
In full mode: Assess all directories (excluding node_modules/, dist/, .git/, .oat/, etc.).
For each directory meeting 1+ primary indicators from the criteria doc:
Link Targets
field with docs topically relevant to the directory scope. Prefer scope-specific docs (e.g., a package README or
package-level docs directory) over project-wide docs. If the directory has a README.md or a nearby docs/ tree,
include those paths as link targets for the new file's References section.Discover cross-cutting file-type patterns that warrant glob-scoped rules. These patterns often span multiple directories, but a concentrated pattern inside a single architectural area can still justify a glob-scoped rule when agents need a repeatable template for that file type.
Follow the systematic process in references/file-type-discovery-checklist.md.
The checklist is the canonical source for the detailed substeps in this phase. The summary below is intentionally shorter than the checklist on purpose. If wording ever diverges, follow the checklist.
Core principle: The goal is not to prove consistency from file counts. The goal is to find non-obvious conventions, competing sub-patterns, and failure modes that would cause an agent to generate the wrong file.
Emphasis points:
AGENTS.md might also mention it.
Glob-scoped rules and directory instructions serve different purposes.40–60% range are often more valuable than perfectly consistent patterns because
they represent active ambiguity in production code.*.spec.ts and
*.page.ts need different guidance, they should usually be separate recommendations rather than one umbrella rule.In delta mode: Still run the full file-type scan. File-type patterns are repo-wide concerns that may not intersect with recently-changed directories but are still high-value for agent correctness.
Record all discovered patterns in the artifact's Glob-Scoped Rule Opportunities table with consistency counts, competing sub-pattern notes, correctness impact, recommended action, and exception-to-rule flags.
If a High/Medium glob opportunity warrants creating, updating, or splitting a rule, also emit it as an explicit item in Recommendations. Do not leave actionable rule work only in the opportunities table.
Skip this step entirely in full mode.
For files changed since the last tracked commit:
Common drift signals:
Skip if only one provider (agents_md) is active.
For glob-scoped rules that target the same file patterns across providers:
Generate the analysis artifact using the template at references/analysis-artifact-template.md.
TIMESTAMP=$(date -u +"%Y-%m-%d-%H%M")
ARTIFACT_PATH=".oat/repo/analysis/agent-instructions-${TIMESTAMP}.md"
BUNDLE_DIR="${ARTIFACT_PATH%.md}.bundle"
SUMMARY_PATH="${BUNDLE_DIR}/summary.md"
MANIFEST_PATH="${BUNDLE_DIR}/recommendations.yaml"
PACKS_DIR="${BUNDLE_DIR}/packs"
mkdir -p "$PACKS_DIR"
Fill in all template sections with findings from Steps 2-7.
Write the human-readable markdown artifact to $ARTIFACT_PATH.
Also write the companion bundle to $BUNDLE_DIR with this layout:
summary.md — rendered from references/bundle-summary-template.mdrecommendations.yaml — rendered from references/recommendations-manifest-template.yamlpacks/<recommendation-id>.md — rendered from references/recommendation-pack-template.mdBundle contract requirements:
Recommendation ID (for example, rec-001)recommendations.yaml must include each recommendation's ID, target, action, disclosure, severity/confidence, and
relative pack pathThe markdown artifact and companion bundle together are the contract for apply. They must contain:
inline, link_only, omit, ask_user)Must Include, Must Not Include, Preferred Default for New Files) for any
recommendation that requires judgment during generationUpdate tracking:
TRACKING_SCRIPT=".oat/scripts/resolve-tracking.sh"
ROOT_TARGET=$(bash "$TRACKING_SCRIPT" root)
ROOT_HASH=$(echo "$ROOT_TARGET" | jq -r '.commitHash')
ROOT_BRANCH=$(echo "$ROOT_TARGET" | jq -r '.baseBranch')
bash "$TRACKING_SCRIPT" write \
agentInstructions \
"$ROOT_HASH" \
"$ROOT_BRANCH" \
"{mode}" \
--artifact-path "$ARTIFACT_PATH" \
{providers...}
Output summary to the user:
Analysis complete.
Files evaluated: {N}
Coverage: {N}% of assessed directories
Mode: {full|delta}
Providers: {list}
Findings:
Critical: {N}
High: {N}
Medium: {N}
Low: {N}
Artifact: {artifact_path}
Bundle: {bundle_dir}
Next step: Run oat-agent-instructions-apply to act on these findings.
AGENTS.override.md discovery and evaluationreferences/docs/agent-instruction.mdreferences/docs/rules-files.mdreferences/docs/cursor-rules-files.md.oat/repo/reviews/github-copilot-instructions-research-2026-02-19.mdreferences/quality-checklist.mdreferences/directory-assessment-criteria.mdreferences/file-type-discovery-checklist.mdreferences/analysis-artifact-template.mdreferences/bundle-summary-template.mdreferences/recommendations-manifest-template.yamlreferences/recommendation-pack-template.md.oat/scripts/resolve-tracking.shscripts/resolve-providers.shscripts/resolve-instruction-files.shdocumentation
Use when OAT implementation changes and repository reference docs must be synchronized. Updates .oat/repo/reference to match current behavior.
business
Merge multiple analysis artifacts into a single coherent report with provenance tracking. Reads existing artifacts from /deep-research, /analyze, and /compare.
testing
Use when the user questions or suspects an agent claim is wrong. Adversarially gathers evidence to verify or refute the claim using the best sources available in the current environment.
tools
Use when prioritizing backlog work or evaluating a roadmap. Produces value-effort ratings, dependency mapping, and execution recommendations.