.agents/skills/oat-agent-instructions-apply/SKILL.md
Run when you have an agent instructions analysis artifact and want to generate or update instruction files. Creates a branch, generates files from templates, and optionally opens a PR.
npx skillsauth add tkstang/open-agent-toolkit oat-agent-instructions-applyInstall 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.
Generate or update agent instruction files based on an analysis artifact, with user review and PR-based workflow.
.oat/repo/analysis/.oat-agent-instructions-analyze first.jq available in PATH (used by helper scripts).gh CLI available for PR creation (optional — manual fallback provided).OAT MODE: Agent Instructions Apply
Purpose: Generate and update instruction files based on analysis findings, with user approval at each step.
BLOCKED Activities:
ALLOWED Activities:
.oat/tracking.json.When this skill needs a user decision:
AskUserQuestion when running in Claude Code with tool availability.Keep the question content consistent across hosts so the workflow remains portable even when the UI differs.
Treat the analysis output as the source of truth for what should be generated and why.
When a companion bundle exists beside the markdown artifact, the bundle is the primary generation contract:
agent-instructions-<timestamp>.bundle/recommendations.yamlagent-instructions-<timestamp>.bundle/packs/*.mdThe markdown artifact remains the human-readable review summary.
Apply may:
Apply must not:
Print a phase banner once at start:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OAT ▸ AGENT INSTRUCTIONS APPLY ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Step indicators:
[1/7] Loading analysis artifact…[2/7] Building recommendation plan…[3/7] Reviewing plan with user…[4/7] Creating branch…[5/7] Generating instruction files…[6/7] Committing + PR…[7/7] Updating tracking + summary…Search for the most recent analysis artifact:
ls -t .oat/repo/analysis/agent-instructions-*.md 2>/dev/null | head -1
If found, derive the companion bundle path:
BUNDLE_DIR="${ARTIFACT_PATH%.md}.bundle"
MANIFEST_PATH="${BUNDLE_DIR}/recommendations.yaml"
If found: Read the artifact, then check for the companion bundle.
Bundle-first behavior:
"$BUNDLE_DIR" exists, validate summary.md, recommendations.yaml, and every referenced pack file.Legacy fallback:
Validate that the artifact includes evidence, confidence, and progressive disclosure decisions for each recommendation.
Also validate that every link_only recommendation includes at least one concrete link target to a canonical doc, config, or example.
If a recommendation updates or contradicts an existing rule, validate that it also includes Content Guidance,
Must Include, Must Not Include, Preferred Default for New Files, and Claim Corrections.
If the artifact records a High/Medium glob-scoped opportunity with a recommended action to create, update, or split a
rule, validate that a matching explicit recommendation exists. Apply should not infer missing rule work from the
opportunities table.
If the companion bundle exists, validate that:
Evidence, Content Guidance, Must Include,
Must Not Include, Counter-Examples, New-File Workflow, Preferred Default for New Files, Claim Corrections)If the artifact is missing that detail, treat it as incomplete:
Analysis artifact is missing evidence-backed recommendation detail.
Re-run oat-agent-instructions-analyze before applying changes.
Then stop.
If not found: Tell the user:
No analysis artifact found in .oat/repo/analysis/.
Run oat-agent-instructions-analyze first to scan the codebase.
Then stop.
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)
The provider list determines which file formats to generate. If running interactively, omit --non-interactive to allow the user to confirm or add providers.
For each recommendation in the analysis artifact, determine the action.
Recommendations may originate from findings, provider baseline gaps, directory coverage gaps, or promoted glob-rule opportunities.
The artifact should already specify the rationale, evidence, confidence, and disclosure decision.
Do not rediscover conventions from scratch during this step.
When the companion bundle exists, build the plan from the bundle manifest and recommendation packs first, then use the
markdown artifact only to confirm reviewer-facing rationale and summary wording.
Carry forward the artifact's structured handoff fields (Content Guidance, Must Include, Must Not Include,
Counter-Examples, New-File Workflow, Preferred Default for New Files, Claim Corrections) into the plan wherever
they are present.
When the companion bundle exists, also carry forward the stable Recommendation ID and Bundle Pack path for each
recommendation so plan review and generation stay aligned to the same pack file.
For provider baseline gaps (always-on provider files):
CLAUDE.md import shims and missing .github/copilot-instructions.md shimsomit, do not include it in the apply planask_user, include it with the evidence and require explicit user approvalFor coverage gaps (new files):
references/instruction-file-templates/agents-md-root.md or agents-md-scoped.mdglob-scoped-rule.md as the canonical body and write a canonical rule file to .agents/rules/{name}.mdomit, do not include it in the apply planask_user, include it with the evidence and require explicit user approvallink_only coverage-gap recommendation has no link target, stop and ask for a fresh analysis instead of guessingFor quality findings (updates to existing files):
omit, do not include it in the apply planask_user, include it with the evidence and require explicit user approvalClaim Corrections and Must Not Include
fields as mandatory constraints rather than optional hintsFor competing sub-patterns in glob-scoped rules:
Multi-format composition order:
@AGENTS.md import exists.agents/rules/{name}.md with YAML frontmatter (description, globs, activation)
oat sync --scope project.claude/rules/*.md, .cursor/rules/*.mdc, or .github/instructions/*.instructions.md.github/copilot-instructions.md from frontmatter/copilot-shim.md templateFill the apply plan template at references/apply-plan-template.md with each recommendation.
Persist the exact markdown plan shown to the user as APPLY_PLAN_MARKDOWN (including recommendation tables and the summary table). This is the source that must be embedded in the PR description.
Present the full recommendation plan to the user first, then ask which review mode they want:
For the review-mode choice:
AskUserQuestionThe prompt should ask for exactly one of: apply all, apply interactively, discuss, cancel.
If the user chooses cancel, output "No actions approved. Exiting." and stop.
If the user chooses apply all:
If the user chooses apply interactively:
AskUserQuestion / Codex structured input when available / plain text fallback)If the user chooses discuss:
apply all, apply interactively, discuss, or cancelIf all recommendations are skipped, output "No actions approved. Exiting." and stop.
Build an APPLIED_PLAN_DETAILS block from approved/modified recommendations with:
approved_via_apply_all / approved / modified)Also build APPLIED_PLAN_MARKDOWN: a markdown block containing only the approved/modified recommendation sections from the presented plan, preserving table formatting.
TIMESTAMP=$(date -u +"%Y-%m-%d-%H%M")
BRANCH="oat/agent-instructions-${TIMESTAMP}"
git checkout -b "$BRANCH"
If branch creation fails (e.g., uncommitted changes), ask the user to resolve and retry.
For each approved recommendation, in the order from Step 2:
Creating new files:
references/instruction-file-templates/.package.json for commands and dependenciesinline → keep the essential rule in the instruction filelink_only → add a concise pointer to the canonical doc/config/exampleomit → do not encode the item in the instruction fileask_user → require explicit user confirmation before writingContent Guidance shapes emphasis and phrasingMust Include is mandatory contentMust Not Include is prohibited contentPreferred Default for New Files determines which sub-pattern new files should followClaim Corrections replaces stale claims in updated files.agents/rules/{name}.mddescription, globs, activation) instead of provider-specific wrappersoat sync --scope project to generate provider-specific rule filesgit check-ignore; if any generated file is ignored,
stop and surface the exact paths before committingUpdating existing files:
Negative rules:
run formatter/lint or a link to the config/doc over prose restatement of the same rule.Required context — read these bundled skill docs before generating:
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 — quality criteria and best practicesreferences/docs/rules-files.md — cross-provider format referencereferences/docs/cursor-rules-files.md — Cursor-specific .mdc format (if cursor provider is active)Stage and commit:
git add {list of generated/updated files}
git commit -m "chore: update agent instruction files
Generated by oat-agent-instructions-apply from analysis artifact.
Files: {count} created, {count} updated."
Offer to open a PR:
After committing, proactively ask the user if they'd like to open a pull request. Frame this as the recommended next step:
Changes committed. Would you like me to push and open a pull request?
The PR will include the applied plan summary and the full analysis artifact for reference.
Use host-specific question handling:
AskUserQuestionIf creating PR:
The PR body must include:
<details> section at the bottom so reviewers can see the evidence behind every change.git push -u origin "$(git rev-parse --abbrev-ref HEAD)"
gh pr create --base main \
--title "chore: update agent instruction files" \
--body "$(cat <<'PRBODY'
## Overview
- Generated/updated agent instruction files based on analysis
- Source: {analysis-artifact-path}
- Providers: {provider-list}
- Result: {N} created, {N} updated, {N} skipped
## Applied Plan Details
The following section is copied from the presented apply plan (`APPLY_PLAN_MARKDOWN`), preserving its tables:
{APPLY_PLAN_MARKDOWN}
## Applied Plan Summary
| Rec # | Action | Target | Provider | Decision | Notes |
|------:|--------|--------|----------|----------|-------|
| {1} | {create/update} | `{path}` | {provider} | {approved/modified} | {note or "-"} |
| ... | ... | ... | ... | ... | ... |
## Changes
{list of files created/updated with brief rationale}
## Verification
- [ ] Instruction files follow quality checklist
- [ ] No content duplication across formats
- [ ] Glob-scoped rules have identical body content across providers
- [ ] Commands referenced in instruction files are valid
- [ ] Every non-obvious convention in generated text is backed by cited analysis evidence
---
## Full Analysis Artifact
The complete analysis that produced these recommendations is included below for reviewer reference.
<details>
<summary>Click to expand full analysis</summary>
{full contents of the analysis artifact markdown file}
</details>
PRBODY
)"
If the user declines PR creation:
Options:
1. Push only (create PR manually)
2. Keep local (no push)
If gh is not available or fails:
PR creation failed. To create manually:
1. Push: git push -u origin {branch}
2. Open PR at your repository's web interface
3. Use the structure above in the PR body, including the full analysis in a collapsible section at the bottom
Update 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 \
agentInstructionsApply \
"$ROOT_HASH" \
"$ROOT_BRANCH" \
"apply" \
{providers...}
Output summary:
Apply complete.
Files created: {N}
Files updated: {N}
Files skipped: {N}
Providers: {list}
Branch: {branch-name}
PR: {URL or "not created"}
Source analysis: {artifact-path}
Tracking updated: .oat/tracking.json
AGENTS.override.md generation and managementreferences/docs/agent-instruction.mdreferences/docs/rules-files.mdreferences/docs/cursor-rules-files.md.oat/repo/analysis/agent-instructions-*.mdreferences/instruction-file-templates/references/apply-plan-template.md.oat/scripts/resolve-tracking.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.