Introduce GitLab monorepo agent instructions
Feedback issue: https://gitlab.com/gitlab-org/gitlab/-/work_items/596611+s
What does this MR do and why?
Establishes a minimal standard for AI agent instruction files in the GitLab monorepo. Only markdown instruction files are committed — no skills, hooks, commands, or tool-specific configs.
Commit 1: Instruction files
- Adds top-level
AGENTS.mdandCLAUDE.md(identical content, kept in sync) - Creates missing
CLAUDE.mdparity files for existing subdirectoryAGENTS.mdfiles (doc/, workhorse/, ee/frontend_islands/) - Updates
.gitignorewith non-rooted patterns forAGENTS.local.md,CLAUDE.local.md, and.ai/* - Updates
.ai/README.mdto document conventions
Commit 2: Doctor lint script
- Implements
scripts/ai_harness/doctorwith--fixsupport using Railway Oriented Programming (Gitlab::Fp::Result) - Validates: parity between CLAUDE.md/AGENTS.md pairs,
.ai/reference resolution,.gitignorecoverage, and no forbidden tool-specific files committed
References
- Introduce GitLab monorepo agent instructions (#594821) • Chad Woolley
- Supersedes GitLab Monorepo AI Harness Configuration Proof ... (#594027 - closed) • Chad Woolley
Screenshots or screen recordings
Not applicable (CLI tooling, no UI changes).
Exploratory Testing
See AI-executed exploratory testing report here
How to set up and validate locally
Integration spec: spec/tooling/ai_harness/doctor/integration_spec.rb
ENABLE_SPRING=1 bin/rspec spec/tooling/ai_harness/doctor/Manual validation:
- Run
scripts/ai_harness/doctorfrom the repo root — all checks should showOK, exit 0 - Delete
CLAUDE.mdand runscripts/ai_harness/doctor— parity check showsFAIL, exit 1 - Run
scripts/ai_harness/doctor --fix—CLAUDE.mdis recreated, parity check showsFIXED, exit 0 - Stage a forbidden file:
mkdir -p .claude/rules && echo '# rule' > .claude/rules/test.md && git add -f .claude/rules/test.md - Run
scripts/ai_harness/doctor— forbidden files check showsFAILwith the file path - Clean up:
git rm -f .claude/rules/test.md && rm -rf .claude/rules - Run
scripts/ai_harness/doctor --help— prints usage, exit 0
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Chad Woolley