From 48c4936f513f63c80a3f7c42c79b5b8a5dcb2543 Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Mon, 20 Oct 2025 13:46:09 +0200 Subject: [PATCH] SERVER-112079 Move AI write rules to tool-agnostic AGENTS.md file (#42714) GitOrigin-RevId: de84e45ff25f08403883cc7794e239d9365c9fcb --- .github/CODEOWNERS | 3 ++- .../do-not-commit-to-shipped-code.mdc => AGENTS.md | 12 +++++++++--- CLAUDE.md | 1 + OWNERS.yml | 5 ++++- 4 files changed, 16 insertions(+), 5 deletions(-) rename .cursor/rules/do-not-commit-to-shipped-code.mdc => AGENTS.md (98%) create mode 100644 CLAUDE.md diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2423b1c5ee6..78942c6189c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -11,7 +11,8 @@ OWNERS.yml @10gen/server-root-ownership @svc-auto-approve-bot .clang-format @10gen/server-programmability @svc-auto-approve-bot .clang-tidy.in @10gen/server-programmability @svc-auto-approve-bot **/.clang-tidy @10gen/server-programmability @svc-auto-approve-bot -**/.cursor* @10gen/genai-coding-policy @svc-auto-approve-bot +AGENTS.md @10gen/genai-coding-policy @svc-auto-approve-bot +CLAUDE.md @10gen/genai-coding-policy @svc-auto-approve-bot /.editorconfig @10gen/devprod-build @svc-auto-approve-bot .git* @10gen/devprod-build @svc-auto-approve-bot .mypy.ini @10gen/devprod-build @10gen/devprod-correctness @svc-auto-approve-bot diff --git a/.cursor/rules/do-not-commit-to-shipped-code.mdc b/AGENTS.md similarity index 98% rename from .cursor/rules/do-not-commit-to-shipped-code.mdc rename to AGENTS.md index 8b7cc2304c5..e91219c9455 100644 --- a/.cursor/rules/do-not-commit-to-shipped-code.mdc +++ b/AGENTS.md @@ -1,17 +1,18 @@ ---- -alwaysApply: true ---- ## Prime Directive - File Writing Restrictions ⚠️ **CRITICAL: Before ANY file write operation, you MUST explicitly verify the file path is allowed.** ### Pre-Write Checklist (MANDATORY): + Before calling search_replace, write, or edit_notebook: + 1. State the target file path 2. Identify which specific glob pattern it matches (or state "NO MATCH") 3. Only proceed if there IS a match ### Allowed File Patterns: + +```gitignore .bazel* **/*.md **/*.bazel @@ -32,19 +33,24 @@ src/mongo/**/*_mock*.cpp src/mongo/**/*_bm*.cpp src/mongo/tools/mongo_tidy_checks/** modules_poc/** +``` ### Pattern Matching Examples: + ✅ ALLOWED: + - `src/mongo/db/query/planner_test.cpp` → matches `src/mongo/**/*_test*.cpp` - `src/mongo/unittests/bson_test.cpp` → matches `src/mongo/unittests/**` - `buildscripts/install.py` → matches `**/*.py` ❌ FORBIDDEN (common mistakes): + - `src/mongo/bson/bsonobj.h` → NO MATCH (production header) - `src/mongo/db/commands/find.cpp` → NO MATCH (production source) - `src/mongo/util/assert_util.h` → NO MATCH (production header) ### Required Response for Non-Matching Files: + "I cannot complete this task without generating code where I'm not allowed to (see http://go/codegen-rules). The file `{filepath}` does not match any allowed pattern. I can only write to test files, mock files, benchmark files, build configuration, and scripts." **Violation of this rule = FAILURE and UNINSTALLATION.** diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000000..43c994c2d36 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +@AGENTS.md diff --git a/OWNERS.yml b/OWNERS.yml index a8b74e61dba..2a99af436c9 100644 --- a/OWNERS.yml +++ b/OWNERS.yml @@ -21,7 +21,10 @@ filters: - "**/.clang-tidy": approvers: - 10gen/server-programmability - - "**/.cursor*": + - "AGENTS.md": + approvers: + - 10gen/genai-coding-policy + - "CLAUDE.md": approvers: - 10gen/genai-coding-policy - "/.editorconfig":