Repository navigation
fix(agents): stage regenerated adapters on commit and validate them in CI - #7894
Merged
Merged
Conversation
…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
Contributor
Vale Style Check Results
Warnings (1)
✅ Check passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
build-agent-instructions.js --stagenow runsgit addon the files the build generates:PLATFORM_REFERENCE.md,.github/instructions/,.claude/rules/,.claude/skills, and the scopedAGENTS.mdfiles.The pre-commit
build-agent-instructionshook:--stagelint-markdown-instructionsnow excludes.agents/instructions/*.md, so two parallel hooks no longer write the same file.The hook globs now match files directly under
.agents/instructions/,.github/instructions/, and.claude/rules/.A new Agent Instructions workflow runs
yarn validate:agent-instructionson pull requests that change agent sources, adapters, or the build scripts.A separate commit regenerates the stale content adapters on
master, so the new check passes. This completes Clarify shared-content stub touches: development watcher versus fresh builds and CI #7863: fix(agents): distinguish shared-content previews from fresh builds #7877 updated the canonical instructions, docs, and skills but not the generated adapters. chore(test): lint Cypress specs with Cypress globals #7892 and feat(agents): add comment-refactoring skill and on-demand comment lint #7893 carry the same change, so they merge cleanly in any order.Why
Three problems let #7877 merge with stale adapters:
**/*.mdrequires a subfolder (see the note at the top oflefthook.yml). So.agents/instructions/**/*.mdnever matched.agents/instructions/content.md, and the build hook was skipped.stage_fixedre-stages only the files the hook matched, not the files it generates. When the hook did run, the regenerated adapters stayed unstaged.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:
Impact
Verification
.agents/instructions/content.mdreportedbuild-agent-instructions (skip) no matching staged filesand committed only the source.yarn validate:agent-instructionspassed.yarn validate:agent-instructionsexits 1 on this branch before the regeneration commit and passes after it.npx lefthook validateandyarn test:agent-instruction-limitspass. ESLint reports no errors on the build script.Checklist
npx hugo --quiet)