mdmanager
Documentation · Grok context
docs/grok.md · mdmanager docs grok

Grok context

mdmanager context --runtime grok reports the instruction Markdown Grok Build loads and the hook files it runs. The model follows Grok Build 2.0.9: its bundled guides plus observed grok inspect --json rows and captured prompts. Context reads the files itself and never runs grok. A later Grok release can change this behavior.

mdmanager context --runtime grok

What loads

Grok loads every instruction file it finds. It never picks one file per directory.

Home sources load in this order:

  1. $GROK_HOME (default ~/.grok), then ~/.claude, then ~/.cursor. From each root, Grok loads the named files (AGENTS.md, CLAUDE.md, CLAUDE.local.md, AGENT.md, and the Agents.md and Claude.md spellings), then .claude/CLAUDE.md and .claude/CLAUDE.local.md, then rules/*.md.
  2. Every entry in [paths] extra_rule_dirs in $GROK_HOME/config.toml, which must be absolute or start with ~/. Grok loads the top-level *.md files in each one, regardless of folder trust, .gitignore, or compatibility cells, even when the directory is inside a repository.

Project sources come from each directory between the Git root and the launch directory. Outside a repository, or when the Git root is your home folder, only the launch directory counts. Each directory contributes, in order: .cursorrules (at the root only), the named files, .claude/CLAUDE*.md, and then the *.md files directly inside .grok/rules, .claude/rules and .cursor/rules.

  • Grok reads only top-level *.md rule files. It never reads .mdc files or subdirectories.
  • Grok ignores rule frontmatter, so it always applies every rule. A Claude rule limited by paths: or a Cursor rule limited by globs: loads in every session.
  • Grok has no size cap and does not expand @ imports. It does not read AGENTS.override.md.
  • A file reached by two paths, through a symlink or a case-insensitive alias, loads once. Context lists the second path as excluded because it is the same file. Identical text under two names loads twice.
  • Grok does not load instruction files below the launch directory at startup, and Context does not scan for them.

Prompt order

Grok sends all instructions in one rules block. Every project file comes first, labeled with its path as an always-applied workspace rule. Every home source follows, without a path, as a user rule the model follows if appropriate. Context lists sources in this prompt order. Grok's own grok inspect and guides list home sources first. That discovery order does not reach the prompt.

Gating

  • Folder trust. Project files load only when $GROK_HOME/trusted_folders.toml trusts the workspace root. Trusting a main checkout also trusts its linked worktrees. Trusting a parent folder does not trust a repository inside it. Your home folder and the filesystem root count as trusted. GROK_FOLDER_TRUST=0 or [folder_trust] enabled = false turns the gate off. Home sources load in every folder. Context lists the project files of an untrusted folder as excluded.
  • .gitignore. Grok skips project files that the repository's root .gitignore ignores. It does not honour .gitignore files in subdirectories, .git/info/exclude, or core.excludesFile, so a CLAUDE.local.md hidden only through .git/info/exclude still reaches Grok. Grok matches each spelling it searches for on its own. On a case-insensitive disk a pattern for Agents.md alone does not skip AGENTS.md, because the later AGENTS.md spelling still finds it; only a pattern that matches every spelling skips the file.
  • Symlinks. Grok skips a project symlink whose target is outside the workspace root. It follows home symlinks to any location.
  • Home routes. A file that a gate keeps out as a project file still loads when a home source also reaches it, such as an extra_rule_dirs entry inside the repository or a GROK_HOME there.
  • Invalid config.toml. While $GROK_HOME/config.toml cannot be parsed, Grok turns every compatibility cell off unless its environment variable turns it on, and ignores extra_rule_dirs. Context reports the parse error and lists the removed files with that reason.

Turn off another runtime's files

Compatibility cells in $GROK_HOME/config.toml decide which Claude and Cursor files Grok reads. Every cell is on by default. An environment variable overrides the TOML value: 0, false, no or off turns the cell off, and 1, true, yes or on turns it on. Context lists each file a cell removes as excluded and names the cell.

Cell Environment variable Files it removes
[compat.claude] agents = false GROK_CLAUDE_AGENTS_ENABLED=0 ~/.claude named files and .claude/CLAUDE*.md in home roots and projects
[compat.claude] rules = false GROK_CLAUDE_RULES_ENABLED=0 ~/.claude/rules and project .claude/rules
[compat.cursor] agents = false GROK_CURSOR_AGENTS_ENABLED=0 ~/.cursor named files and ~/.cursor/.claude/CLAUDE*.md
[compat.cursor] rules = false GROK_CURSOR_RULES_ENABLED=0 ~/.cursor/rules, project .cursor/rules, and .cursorrules

No cell removes a project's root CLAUDE.md, CLAUDE.local.md or AGENTS.md, or the named files in $GROK_HOME. mdmanager never edits Grok configuration. Ask your coding agent to set a cell, then confirm the result with mdmanager context --runtime grok.

Hide a Claude local disable from Grok

Grok ignores claudeMdExcludes. Disabling a file for Claude in .claude/settings.local.json, including with mdmanager local disable claude, leaves Grok's view unchanged: a file Grok loads keeps loading, and one a Grok gate already removes stays excluded. To hide a loaded file from Grok as well, ignore it in the repository's root .gitignore, a shared change. For .claude/CLAUDE.md, .claude/CLAUDE.local.md or a .claude/rules file, the matching [compat.claude] cell in the table above also works, but hides every such Claude file from Grok. mdmanager has no Grok local disable. Check the result with mdmanager context --runtime grok.

Duplicate instructions

Context warns when the same instructions reach Grok twice; see duplicate instructions for what counts. Grok drops rule frontmatter, and two paths to one file load once. Two common causes:

  • The Claude Global target ~/.claude/CLAUDE.md loads alongside a Grok home file that carries the same Sections. Turn off [compat.claude] agents, or keep Grok from getting a second copy. A Global grok target gets its own warning that names the fix; see Managed files.
  • A project's root AGENTS.md and root CLAUDE.md both load. Keep only Claude-specific Sections in CLAUDE.md, plus an @AGENTS.md line. Grok sends that line as plain text and loads AGENTS.md once. mdmanager renders a Project CLAUDE.md this way beside an agents target.

Hooks

Context lists every hook file Grok reads for the launch directory, after the instructions, under HOOKS. JSON output carries them in hooks. Each file shows its origin (Grok, Claude, Cursor or a plugin), the events and commands it registers, and whether each one runs. mdmanager only reports hooks. It never edits, deploys or turns off hook settings.

Grok reads hook files in this order. When the same command is registered more than once, Grok runs it once per call, from the first copy whose matcher selects that call. Context lists a later copy as not run when earlier copies select every call it does: an earlier copy without a matcher or with the same matcher, or, for SessionStart, earlier copies that cover its new and load sources. Any other later copy runs for the calls the earlier ones leave, and Context notes which copy takes the rest. Context warns once per repeated command and names the files. A missing env and an empty one count as the same.

  1. [[hooks.<Event>]] tables in $GROK_HOME/config.toml.
  2. $GROK_HOME/hooks/*.json, alphabetically.
  3. ~/.claude/settings.json, then ~/.claude/settings.local.json.
  4. ~/.cursor/hooks.json.
  5. For each directory from the workspace root to the launch directory: .claude/settings.json, .claude/settings.local.json, .grok/hooks/*.json, then .cursor/hooks.json. Launched in your home folder or at the filesystem root, Grok reads no project hook files.
  6. Each enabled plugin's hooks/hooks.json. Grok looks for plugins in this order: the workspace root's .grok/plugins/ and .claude/plugins/, $GROK_HOME/plugins/, ~/.claude/plugins/, plugins installed with grok plugin install, then each [plugins] paths folder. When two plugins share a name, Grok loads only the first, even one an untrusted folder holds back. Context lists the hidden plugin as not run. A plugin runs only while [plugins] enabled names it, by name or ID, and [plugins] disabled does not; a [plugins] paths plugin is on unless disabled, and Grok trusts it only inside your home folder. A plugin's copy of a command is its own and never merges with another file's.

What keeps a hook from running:

  • Folder trust. Project hook files and project plugins run only in a trusted folder, as for project instructions. In an untrusted folder, Context also warns that an interactive session holds back your own hooks until you trust the folder; headless grok -p runs them.
  • Compatibility cells. [compat.claude] hooks = false or GROK_CLAUDE_HOOKS_ENABLED=0 turns off every .claude/settings*.json file. [compat.cursor] hooks = false or GROK_CURSOR_HOOKS_ENABLED=0 turns off every .cursor/hooks.json. Context lists their hooks as not run and names the cell. Neither cell affects plugins.
  • Cursor's own entries. Grok runs a hooks.json matcher group (an entry with a hooks list) like any other hook. Cursor's own entries, written without a hooks list, run only under preToolUse, only from ~/.cursor/hooks.json or the root's .cursor/hooks.json, and only while [features] cursor_hook_entries is on. It is off by default, and GROK_CURSOR_HOOK_ENTRIES=1 turns it on. Such an entry also gives way to any other hook that runs the same command.
  • Handlers Grok cannot run. Grok skips handlers that are not command or http, such as Claude's prompt and agent hooks, a command handler without a command, an http handler without a url, handlers that set if, matchers that are not valid regular expressions, and events it does not know, such as Claude's PermissionRequest.
  • SessionStart matchers. Grok's SessionStart matcher sees only new or load. A Claude matcher such as startup|resume|clear|compact never fires under Grok, so Context lists it as not run. On other events Context checks only that a matcher is valid, not which calls it selects.

Context warns when Claude or Cursor hooks run. Grok runs them with CLAUDE_PROJECT_DIR set and without CLAUDECODE or any other Claude marker. A hook written for Claude therefore believes it runs under Claude unless it checks GROK_AGENT or GROK_HOOK_EVENT. When a repeated command has a copy in a Cursor hooks.json, Grok also reads its reply by Cursor's rules and keeps the stricter result; the duplicate warning says so.

Context does not model organization hooks (managed_config.toml, requirements.toml, /etc/grok, allow_managed_hooks_only), hooks-paths, agent frontmatter hooks:, hooks you turned off in Grok's Hooks tab (~/.grok/disabled-hooks), plugins loaded with --plugin-dir, plugin manifests that move hooks/hooks.json, installed repositories holding several plugins, or Cursor's matcher and field checks. When in doubt, compare with grok inspect.

Managed files

  • The Global target grok, created by mdmanager init grok, is the user rule $GROK_HOME/rules/mdmanager.md (default ~/.grok/rules/mdmanager.md). Grok loads it in every folder, trusted or not, and no other runtime reads it. It renders plain Markdown, since Grok ignores rule frontmatter. Any .md file directly in ~/.grok/rules or $GROK_HOME/rules can be a Global target. A named file directly in ~/.grok or $GROK_HOME, such as ~/.grok/AGENTS.md or ~/.grok/AGENT.md, is refused: Grok loads those named files, but its documentation names only rules/*.md as the user rule location. Context still lists a named file there when it exists.
  • While [compat.claude] agents is on, Grok also reads the Claude Global target ~/.claude/CLAUDE.md, so it gets both Global compositions. While Grok loads both that file and a Global Grok rule target, from any Profile, Context and mdmanager status warn and name the fix. Both check what Grok loads when launched in the current directory, so a Grok rule that is not applied, or sits outside a GROK_HOME that moved, gets no warning: apply it first, because the fix leaves Grok only its own rules. Give Grok only its own target:

toml # ~/.grok/config.toml [compat.claude] agents = false

or export GROK_CLAUDE_AGENTS_ENABLED=0. The cell also turns off every project's .claude/CLAUDE.md and .claude/CLAUDE.local.md, but not a root CLAUDE.md. - Grok reads neither ~/.codex/AGENTS.md nor the Cursor rule ~/.cursor/rules/mdmanager.mdc. - Grok loads both Project Instruction files, root AGENTS.md and root CLAUDE.md. Beside an agents target the rendered CLAUDE.md holds only an @AGENTS.md line and Claude-only Sections, so Grok gets each shared Section once. - The Local file CLAUDE.local.md reaches Grok as well as Claude. Grok has nothing like AGENTS.override.md.

Context does not read a project's .grok/config.toml, managed Grok configuration, or requirements.toml. Skills, text passed with --rules, and system prompts are outside its scope.