Skip to content

Commit d10f050

Browse files
authored
feat: add agent instructions artifact bundle handoff (#86)
1 parent 595435e commit d10f050

14 files changed

Lines changed: 1578 additions & 16 deletions

File tree

‎.agents/skills/oat-agent-instructions-analyze/SKILL.md‎

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: oat-agent-instructions-analyze
3-
version: 1.7.0
3+
version: 1.9.0
44
description: 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.
55
disable-model-invocation: true
66
user-invocable: true
@@ -37,8 +37,13 @@ Scan, evaluate, and report on agent instruction file coverage, quality, and drif
3737
## Analyze vs Apply Boundary
3838

3939
`oat-agent-instructions-analyze` owns discovery, evaluation, evidence gathering, and recommendation shaping.
40-
The analysis artifact must be detailed enough that `oat-agent-instructions-apply` can execute approved
41-
recommendations without rediscovering repo conventions from scratch.
40+
Its output now has two layers:
41+
42+
- a human-readable review artifact (`agent-instructions-<timestamp>.md`)
43+
- a machine-oriented companion bundle (`agent-instructions-<timestamp>.bundle/`)
44+
45+
The markdown artifact is for reviewers. The bundle is the generation contract that `oat-agent-instructions-apply`
46+
should consume when it exists.
4247

4348
`oat-agent-instructions-apply` may verify that cited files still exist and may read those same cited
4449
sources while generating output, but it must not invent unsupported conventions, create new recommendations,
@@ -390,11 +395,35 @@ Generate the analysis artifact using the template at `references/analysis-artifa
390395
```bash
391396
TIMESTAMP=$(date -u +"%Y-%m-%d-%H%M")
392397
ARTIFACT_PATH=".oat/repo/analysis/agent-instructions-${TIMESTAMP}.md"
398+
BUNDLE_DIR="${ARTIFACT_PATH%.md}.bundle"
399+
SUMMARY_PATH="${BUNDLE_DIR}/summary.md"
400+
MANIFEST_PATH="${BUNDLE_DIR}/recommendations.yaml"
401+
PACKS_DIR="${BUNDLE_DIR}/packs"
402+
mkdir -p "$PACKS_DIR"
393403
```
394404

395405
Fill in all template sections with findings from Steps 2-7.
396406

397-
The artifact is the contract for apply. It must contain:
407+
Write the human-readable markdown artifact to `$ARTIFACT_PATH`.
408+
409+
Also write the companion bundle to `$BUNDLE_DIR` with this layout:
410+
411+
- `summary.md` — rendered from `references/bundle-summary-template.md`
412+
- `recommendations.yaml` — rendered from `references/recommendations-manifest-template.yaml`
413+
- `packs/<recommendation-id>.md` — rendered from `references/recommendation-pack-template.md`
414+
415+
Bundle contract requirements:
416+
417+
- every recommendation gets a stable `Recommendation ID` (for example, `rec-001`)
418+
- the markdown artifact, manifest, and pack filenames must agree on that ID
419+
- `recommendations.yaml` must include each recommendation's ID, target, action, disclosure, severity/confidence, and
420+
relative `pack` path
421+
- each pack must preserve the recommendation's evidence refs, structural conventions, behavioral conventions,
422+
counter-examples, new-file workflow, preferred default, and claim corrections
423+
- if the markdown artifact and bundle ever diverge, the bundle is the apply contract and the markdown artifact is the
424+
review summary
425+
426+
The markdown artifact and companion bundle together are the contract for apply. They must contain:
398427

399428
- exact evidence references for each finding and recommendation
400429
- confidence for each recommendation
@@ -403,8 +432,7 @@ The artifact is the contract for apply. It must contain:
403432
- claim-correction details when updating or contradicting existing rules
404433
- content-guidance fields (`Must Include`, `Must Not Include`, `Preferred Default for New Files`) for any
405434
recommendation that requires judgment during generation
406-
407-
Write the artifact to `$ARTIFACT_PATH`.
435+
- stable recommendation IDs and pack references for any recommendation that apply may execute
408436

409437
### Step 9: Update Tracking and Output Summary
410438

@@ -441,6 +469,7 @@ Analysis complete.
441469
Low: {N}
442470
443471
Artifact: {artifact_path}
472+
Bundle: {bundle_dir}
444473
445474
Next step: Run oat-agent-instructions-apply to act on these findings.
446475
```
@@ -461,6 +490,9 @@ Next step: Run oat-agent-instructions-apply to act on these findings.
461490
- Directory criteria: `references/directory-assessment-criteria.md`
462491
- File-type discovery: `references/file-type-discovery-checklist.md`
463492
- Artifact template: `references/analysis-artifact-template.md`
493+
- Bundle summary template: `references/bundle-summary-template.md`
494+
- Bundle manifest template: `references/recommendations-manifest-template.yaml`
495+
- Recommendation pack template: `references/recommendation-pack-template.md`
464496
- Tracking script: `scripts/resolve-tracking.sh`
465497
- Provider resolution: `scripts/resolve-providers.sh`
466498
- File discovery: `scripts/resolve-instruction-files.sh`

‎.agents/skills/oat-agent-instructions-analyze/references/analysis-artifact-template.md‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ oat_analysis_commit: { commitHash }
1414
**Providers:** {agents_md, claude, cursor, ...}
1515
**Commit:** {short-hash}
1616

17+
## Bundle Outputs
18+
19+
The companion bundle for this analysis lives beside the markdown artifact and is the primary generation contract for
20+
`oat-agent-instructions-apply` when present.
21+
22+
| Path | Purpose |
23+
| ----------------------------------- | --------------------------------------------- |
24+
| `{artifact-path}` | Human-readable review artifact |
25+
| `{bundle-dir}/summary.md` | Compact bridge summary for apply-time context |
26+
| `{bundle-dir}/recommendations.yaml` | Manifest of executable recommendations |
27+
| `{bundle-dir}/packs/` | Recommendation-scoped packs |
28+
29+
Every recommendation below should include a stable `Recommendation ID` that maps to exactly one pack file.
30+
1731
## Summary
1832

1933
- **Files evaluated:** {N}
@@ -173,8 +187,10 @@ Capture which details should live in always-on instructions versus linked docume
173187
Prioritized actions based on findings above.
174188

175189
1. **{Action}** — {rationale} (addresses finding #{N})
190+
- Recommendation ID: `rec-001`
176191
- Target: `{path}`
177192
- Provider/Format: {provider / format}
193+
- Bundle Pack: `{bundle-dir}/packs/rec-001.md`
178194
- Evidence: {exact refs}
179195
- Confidence: {high | medium | low}
180196
- Disclosure: {inline | link_only | omit | ask_user}
@@ -185,8 +201,10 @@ Prioritized actions based on findings above.
185201
- Preferred Default for New Files: {pattern A / pattern B / N/A}
186202
- Claim Corrections: {`old claim -> verified replacement` or `none`}
187203
2. **{Action}** — {rationale} (addresses provider baseline gap #{N})
204+
- Recommendation ID: `rec-002`
188205
- Target: `{path}`
189206
- Provider/Format: {provider / format}
207+
- Bundle Pack: `{bundle-dir}/packs/rec-002.md`
190208
- Evidence: {exact refs}
191209
- Confidence: {high | medium | low}
192210
- Disclosure: {inline | link_only | omit | ask_user}
@@ -197,8 +215,10 @@ Prioritized actions based on findings above.
197215
- Preferred Default for New Files: {pattern A / pattern B / N/A}
198216
- Claim Corrections: {`old claim -> verified replacement` or `none`}
199217
3. **{Action}** — {rationale} (addresses gap #{N})
218+
- Recommendation ID: `rec-003`
200219
- Target: `{path}`
201220
- Provider/Format: {provider / format}
221+
- Bundle Pack: `{bundle-dir}/packs/rec-003.md`
202222
- Evidence: {exact refs}
203223
- Confidence: {high | medium | low}
204224
- Disclosure: {inline | link_only | omit | ask_user}
@@ -212,7 +232,10 @@ Prioritized actions based on findings above.
212232

213233
## Apply Contract
214234

215-
- `oat-agent-instructions-apply` may only implement recommendations backed by evidence in this artifact.
235+
- `oat-agent-instructions-apply` may only implement recommendations backed by evidence in this artifact and its
236+
companion bundle.
237+
- When the companion bundle exists, apply should treat `recommendations.yaml` plus `packs/*.md` as the primary
238+
generation contract and use this markdown artifact as reviewer context.
216239
- Recommendations marked `omit` must stay out of generated instructions.
217240
- Recommendations marked `ask_user` require explicit user confirmation before generation.
218241
- If cited config/docs/files are missing at apply time, stop and re-run analyze or ask the user rather than inventing a replacement rule.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
bundle_version: 1
3+
analysis_artifact: { artifact-path }
4+
manifest: recommendations.yaml
5+
pack_count: { N }
6+
generated_at: { YYYY-MM-DD }
7+
---
8+
9+
# Agent Instructions Analysis Bundle Summary
10+
11+
Companion bundle for `{artifact-path}`.
12+
13+
## Purpose
14+
15+
This bundle is the machine-oriented handoff for `oat-agent-instructions-apply`.
16+
The markdown analysis artifact remains the reviewer-facing summary. If they diverge, the bundle wins for generation.
17+
18+
## Recommendation Index
19+
20+
| ID | Action | Target | Provider / Format | Pack | Notes |
21+
| --------- | --------------- | -------- | ------------------- | ------------------ | ----------------- |
22+
| `rec-001` | {create/update} | `{path}` | {provider / format} | `packs/rec-001.md` | {short rationale} |
23+
| ... | | | | | |
24+
25+
## Validation Rules
26+
27+
- Every recommendation in `recommendations.yaml` must appear in this table.
28+
- Every listed pack file must exist under `packs/`.
29+
- Recommendation IDs must match across the markdown artifact, the manifest, and the pack filename.
30+
- Apply may use this summary for quick context, but it should load the manifest and matching pack before generating
31+
output.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Recommendation Pack: `rec-001`
2+
3+
## Target
4+
5+
- Action: {create / update}
6+
- Path: `{path}`
7+
- Provider / Format: {provider / format}
8+
- Disclosure: {inline / link_only / omit / ask_user}
9+
10+
## Evidence
11+
12+
- `{path}:{line}` - {why this evidence matters}
13+
- `{path}:{line}` - {supporting configuration, docs, or code pattern}
14+
15+
## Structural Conventions
16+
17+
- {imports, exports, file layout, frontmatter, or structural template rules}
18+
19+
## Behavioral Conventions
20+
21+
- {delegation, sequencing, runtime behavior, workflow rules, or architecture expectations}
22+
23+
## Counter-Examples
24+
25+
- {common mistake or anti-pattern}
26+
- {structurally valid but architecturally wrong output}
27+
28+
## New-File Workflow
29+
30+
1. {creation or wiring step}
31+
2. {registration, sync, or follow-up step}
32+
33+
## Preferred Default for New Files
34+
35+
{pattern A / pattern B / N/A}
36+
37+
## Claim Corrections
38+
39+
- `{old claim -> verified replacement}`
40+
41+
## Generation Constraints
42+
43+
- Must Include: {required claims, commands, references, examples, or behavior}
44+
- Must Not Include: {unsupported or stale guidance}
45+
- Link Targets: {path / URL or `N/A`}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
bundleVersion: 1
2+
analysisArtifact: { artifact-path }
3+
summary: summary.md
4+
recommendations:
5+
- id: rec-001
6+
action: create
7+
target: path/to/file
8+
provider: agents_md
9+
format: AGENTS.md
10+
severity: high
11+
confidence: high
12+
disclosure: inline
13+
pack: packs/rec-001.md
14+
- id: rec-002
15+
action: update
16+
target: path/to/existing-file
17+
provider: cursor
18+
format: glob-rule
19+
severity: medium
20+
confidence: medium
21+
disclosure: link_only
22+
pack: packs/rec-002.md
23+
24+
# Rules:
25+
# - Every recommendation referenced here must also exist in the markdown analysis artifact.
26+
# - `pack` must be a relative path under this bundle directory.
27+
# - The manifest is the primary index used by oat-agent-instructions-apply when the bundle exists.

‎.agents/skills/oat-agent-instructions-apply/SKILL.md‎

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: oat-agent-instructions-apply
3-
version: 1.4.0
3+
version: 1.6.1
44
description: 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.
55
disable-model-invocation: true
66
user-invocable: true
@@ -50,7 +50,14 @@ Keep the question content consistent across hosts so the workflow remains portab
5050

5151
## Analyze vs Apply Boundary
5252

53-
Treat the analysis artifact as the source of truth for what should be generated and why.
53+
Treat the analysis output as the source of truth for what should be generated and why.
54+
55+
When a companion bundle exists beside the markdown artifact, the bundle is the primary generation contract:
56+
57+
- `agent-instructions-<timestamp>.bundle/recommendations.yaml`
58+
- `agent-instructions-<timestamp>.bundle/packs/*.md`
59+
60+
The markdown artifact remains the human-readable review summary.
5461

5562
Apply may:
5663

@@ -92,7 +99,26 @@ Search for the most recent analysis artifact:
9299
ls -t .oat/repo/analysis/agent-instructions-*.md 2>/dev/null | head -1
93100
```
94101

95-
**If found:** Read the artifact, extract findings and recommendations.
102+
If found, derive the companion bundle path:
103+
104+
```bash
105+
BUNDLE_DIR="${ARTIFACT_PATH%.md}.bundle"
106+
MANIFEST_PATH="${BUNDLE_DIR}/recommendations.yaml"
107+
```
108+
109+
**If found:** Read the artifact, then check for the companion bundle.
110+
111+
**Bundle-first behavior:**
112+
113+
- If `"$BUNDLE_DIR"` exists, validate `summary.md`, `recommendations.yaml`, and every referenced pack file.
114+
- Treat the bundle as the primary generation contract and the markdown artifact as review context.
115+
- If the bundle exists but is incomplete, stop and require a refreshed analysis rather than falling back silently to the
116+
markdown artifact.
117+
118+
**Legacy fallback:**
119+
120+
- If no companion bundle exists, continue using the markdown artifact alone.
121+
- This keeps apply backward compatible with older analysis artifacts until the bundle contract is fully adopted.
96122

97123
Validate that the artifact includes evidence, confidence, and progressive disclosure decisions for each recommendation.
98124
Also validate that every `link_only` recommendation includes at least one concrete link target to a canonical doc, config, or example.
@@ -101,6 +127,13 @@ If a recommendation updates or contradicts an existing rule, validate that it al
101127
If the artifact records a High/Medium glob-scoped opportunity with a recommended action to create, update, or split a
102128
rule, validate that a matching explicit recommendation exists. Apply should not infer missing rule work from the
103129
opportunities table.
130+
If the companion bundle exists, validate that:
131+
132+
- every recommendation has a stable ID
133+
- every manifest entry points to an existing pack file
134+
- each pack preserves the executable fields apply relies on (`Evidence`, `Content Guidance`, `Must Include`,
135+
`Must Not Include`, `Counter-Examples`, `New-File Workflow`, `Preferred Default for New Files`, `Claim Corrections`)
136+
104137
If the artifact is missing that detail, treat it as incomplete:
105138

106139
```
@@ -134,8 +167,13 @@ For each recommendation in the analysis artifact, determine the action.
134167
Recommendations may originate from findings, provider baseline gaps, directory coverage gaps, or promoted glob-rule opportunities.
135168
The artifact should already specify the rationale, evidence, confidence, and disclosure decision.
136169
Do not rediscover conventions from scratch during this step.
170+
When the companion bundle exists, build the plan from the bundle manifest and recommendation packs first, then use the
171+
markdown artifact only to confirm reviewer-facing rationale and summary wording.
137172
Carry forward the artifact's structured handoff fields (`Content Guidance`, `Must Include`, `Must Not Include`,
138-
`Preferred Default for New Files`, `Claim Corrections`) into the plan wherever they are present.
173+
`Counter-Examples`, `New-File Workflow`, `Preferred Default for New Files`, `Claim Corrections`) into the plan wherever
174+
they are present.
175+
When the companion bundle exists, also carry forward the stable `Recommendation ID` and `Bundle Pack` path for each
176+
recommendation so plan review and generation stay aligned to the same pack file.
139177

140178
**For provider baseline gaps (always-on provider files):**
141179

@@ -254,10 +292,15 @@ If branch creation fails (e.g., uncommitted changes), ask the user to resolve an
254292

255293
For each approved recommendation, in the order from Step 2:
256294

295+
- When the companion bundle exists, load the approved recommendation's manifest entry and matching pack before
296+
reading repo evidence or generating content.
297+
- Treat that pack as the executable contract for the recommendation. Do not generate from the markdown summary alone.
298+
257299
**Creating new files:**
258300

259301
1. Read the appropriate template from `references/instruction-file-templates/`.
260302
2. Read only the project context needed to fill the approved recommendation:
303+
- the matching recommendation pack when the companion bundle exists
261304
- the evidence files cited in the artifact
262305
- `package.json` for commands and dependencies
263306
- directory structure for architecture section
@@ -284,7 +327,7 @@ For each approved recommendation, in the order from Step 2:
284327

285328
**Updating existing files:**
286329

287-
1. Read the existing file.
330+
1. Read the existing file and the matching recommendation pack when the companion bundle exists.
288331
2. Identify the section(s) that need updating based on the finding.
289332
3. Make targeted edits using only the approved recommendation and its cited evidence.
290333
4. Do not rewrite the entire file unless the user explicitly approves.

‎.agents/skills/oat-agent-instructions-apply/references/apply-plan-template.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ oat_providers: [{ providers }]
1010

1111
**Date:** {YYYY-MM-DD}
1212
**Source Analysis:** `{analysis-artifact-path}`
13+
**Source Bundle:** `{bundle-path or legacy-markdown-only}`
1314
**Providers:** {agents_md, claude, cursor, ...}
1415

1516
## Instructions
@@ -36,10 +37,12 @@ If a recommendation lacks that detail, it should be blocked pending a fresh anal
3637

3738
| Field | Value |
3839
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
40+
| Recommendation ID | `rec-001` |
3941
| Action | {create / update} |
4042
| Provider | {agents_md / claude / cursor / copilot} |
4143
| Format | {AGENTS.md / Claude rule / Cursor rule / Copilot instruction / Copilot shim} |
4244
| Target | `{target-file-path}` |
45+
| Bundle Pack | `{bundle-dir}/packs/rec-001.md` or `legacy-markdown-only` |
4346
| Rationale | {Why — references analysis finding #N or coverage gap #N} |
4447
| Evidence | {exact file refs / config / docs that justify the recommendation} |
4548
| Confidence | {high / medium / low} |

0 commit comments

Comments
 (0)