zed/crates/zed/src
Richard Feldman 29ca37fdcc
Load global AGENTS.md into native agent system prompt (#56757)
Watches a user-global `AGENTS.md` file alongside `settings.json` (at
`~/.config/zed/AGENTS.md` on macOS/Linux, `%APPDATA%\Zed\AGENTS.md` on
Windows) and includes its trimmed contents in the native agent's system
prompt.

This matches the pattern used by Codex (`CODEX_HOME/AGENTS.md`,
defaulting to `~/.codex/AGENTS.md`) and OpenCode
(`~/.config/opencode/AGENTS.md`): personal instructions live next to
other app config and apply across every project the user opens.

## Behavior

- Native Zed agent only. Not passed to ACP / external agents.
- Reads the local config dir, so SSH-remoted projects still get the
local user's personal `AGENTS.md` (project rules continue to come from
the remote workspace).
- Missing, empty, or whitespace-only files are silently treated as no
`AGENTS.md`.
- Read errors surface through the same notification UI as settings
errors, with a stable notification ID that's dismissed once the file
becomes readable again.
- The file is read in full, matching how existing project rules / repo
`AGENTS.md` files are loaded today.

## System prompt rendering

In the system prompt, the user-global `AGENTS.md` appears as `###
Personal AGENTS.md` immediately before `### Project Rules`, so the model
sees personal defaults first and project guidance later (project rules
take precedence on conflicts).

## Tests

- `user_agents_md` watcher: initial load, empty/whitespace ignored,
reacts to file edits.
- `SystemPromptTemplate`: renders personal `AGENTS.md` before project
rules; omits the section when no user `AGENTS.md` is present.

Closes AI-231

Release Notes:

- Added support for a global `AGENTS.md` file alongside `settings.json`
that is automatically included in the agent's instructions for every
project.
2026-05-14 15:02:33 +00:00
..
zed Support SCP style SSH URLs (#56304) 2026-05-13 02:05:59 +00:00
main.rs Load global AGENTS.md into native agent system prompt (#56757) 2026-05-14 15:02:33 +00:00
reliability.rs Merge gpui::Task and scheduler::Task (#53674) 2026-05-05 22:41:13 +00:00
visual_test_runner.rs acp: Use new Rust SDK (#52997) 2026-04-22 15:02:57 +00:00
zed.rs Load global AGENTS.md into native agent system prompt (#56757) 2026-05-14 15:02:33 +00:00