Skip to content

fix(agents): stage regenerated adapters on commit and validate them in CI - #7894

Merged
jstirnaman merged 2 commits into
masterfrom
chore/agent-adapter-sync
Oct 14, 2026
Merged

jstirnaman merged 2 commits into
masterfrom
chore/agent-adapter-sync

Conversation

@jstirnaman

@jstirnaman jstirnaman commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #7863.

Related: #7877, #7892, and #7893. This PR partly addresses #7094 by checking generated agent instructions in CI instead of relying on local hooks.

What changed

Why

Three problems let #7877 merge with stale adapters:

  1. The hook never ran. Lefthook's **/*.md requires a subfolder (see the note at the top of lefthook.yml). So .agents/instructions/**/*.md never matched .agents/instructions/content.md, and the build hook was skipped.
  2. The output wasn't committed. stage_fixed re-stages only the files the hook matched, not the files it generates. When the hook did run, the regenerated adapters stayed unstaged.
  3. A race with the formatter. Pre-commit runs in parallel. The Markdown formatter could rewrite a source after the build had read it, so the committed adapters wouldn't match the committed source.

Hooks can also be skipped with --no-verify, by web edits, or on machines without them installed, so CI now checks the result.

I chose a failing check over having CI regenerate and commit:

  • Bot pushes made with the default workflow token don't trigger CI, so the new head would go untested.
  • The bot can't push to branches from forks.
  • Authors would have to pull a bot commit before their next push.

Impact

  • Committing an instruction change also commits its formatted source and the matching adapters.
  • Pull requests with stale or invalid adapters fail the new check, with the fix command in the error message.

Verification

  • Hook, before: on a throwaway branch, committing an edit to .agents/instructions/content.md reported build-agent-instructions (skip) no matching staged files and committed only the source.
  • Hook, after: the same unformatted edit committed the formatted source and all three content adapters. Nothing was left unstaged, and yarn validate:agent-instructions passed.
  • CI check: yarn validate:agent-instructions exits 1 on this branch before the regeneration commit and passes after it.
  • npx lefthook validate and yarn test:agent-instruction-limits pass. ESLint reports no errors on the build script.

Checklist

…n CI

What changed:
- Add a --stage flag to build-agent-instructions.js that git-adds the
  files it generates: PLATFORM_REFERENCE.md, .github/instructions,
  .claude/rules, .claude/skills, and the scoped AGENTS.md files.
- Run the pre-commit build with --stage, format staged instruction
  sources before building, and exclude those sources from the parallel
  lint-markdown-instructions hook.
- Match files directly under .agents/instructions, .github/instructions,
  and .claude/rules. The previous **/*.md globs required a subfolder.
- Add the Agent Instructions workflow, which runs
  yarn validate:agent-instructions on pull requests that touch agent
  sources, adapters, or the build scripts.

Why:
- The build hook never ran for .agents/instructions/*.md because of the
  glob. When it did run, stage_fixed re-staged only the matched sources,
  so commits shipped without their regenerated adapters. #7877 merged
  that way.
- The parallel remark hook could reformat a source after the build read
  it, so the committed adapters would not match the committed source.
- Hooks can be skipped, so CI must check the result.

Impact:
- Committing an instruction change commits its formatted source and
  matching adapters together.
- Pull requests with stale or invalid adapters fail the new check.

Verification:
- On a throwaway branch, committing an unformatted edit to
  .agents/instructions/content.md committed the formatted source and all
  three content adapters, left nothing unstaged, and
  yarn validate:agent-instructions passed. Before the fix, the build hook
  was skipped and the adapters stayed stale.
- yarn validate:agent-instructions exits 1 on this branch before the
  adapter regeneration commit.
- npx lefthook validate passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018NiFuxdSqYvtMpAhNfWBbM
What changed:
- Regenerate .claude/rules/content.md,
  .github/instructions/content.instructions.md, and content/AGENTS.md
  from .agents/instructions/content.md.

Why:
- #7877 updated the shared-content guidance in .agents/instructions but
  not the generated adapters, so yarn validate:agent-instructions fails
  on master and the commit hooks rewrite these files on every run.

Impact:
- Agents that read the adapters get the current shared-content preview
  guidance.

Verification:
- yarn validate:agent-instructions passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018NiFuxdSqYvtMpAhNfWBbM
@jstirnaman
jstirnaman requested a review from a team as a code owner October 14, 2026 11:23
@jstirnaman
jstirnaman requested review from sanderson and removed request for a team October 14, 2026 11:23
@github-actions

Copy link
Copy Markdown
Contributor

Vale Style Check Results

Metric Count
Errors 0
Warnings 1
Warnings (1)
File Line Rule Message
content/AGENTS.md 120 Google.Colons ': S' should be in lowercase.

✅ Check passed

@jstirnaman
jstirnaman merged commit 6f93f18 into master Oct 14, 2026
29 checks passed
@jstirnaman
jstirnaman deleted the chore/agent-adapter-sync branch October 14, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify shared-content stub touches: development watcher versus fresh builds and CI

2 participants