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.md and CLAUDE.md (identical content, kept in sync)
  • Creates missing CLAUDE.md parity files for existing subdirectory AGENTS.md files (doc/, workhorse/, ee/frontend_islands/)
  • Updates .gitignore with non-rooted patterns for AGENTS.local.md, CLAUDE.local.md, and .ai/*
  • Updates .ai/README.md to document conventions

Commit 2: Doctor lint script

  • Implements scripts/ai_harness/doctor with --fix support using Railway Oriented Programming (Gitlab::Fp::Result)
  • Validates: parity between CLAUDE.md/AGENTS.md pairs, .ai/ reference resolution, .gitignore coverage, and no forbidden tool-specific files committed

References

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:

  1. Run scripts/ai_harness/doctor from the repo root — all checks should show OK, exit 0
  2. Delete CLAUDE.md and run scripts/ai_harness/doctor — parity check shows FAIL, exit 1
  3. Run scripts/ai_harness/doctor --fixCLAUDE.md is recreated, parity check shows FIXED, exit 0
  4. Stage a forbidden file: mkdir -p .claude/rules && echo '# rule' > .claude/rules/test.md && git add -f .claude/rules/test.md
  5. Run scripts/ai_harness/doctor — forbidden files check shows FAIL with the file path
  6. Clean up: git rm -f .claude/rules/test.md && rm -rf .claude/rules
  7. 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

Merge request reports

Loading