website/docs/user-guide/features/context-files.md
Hermes Agent automatically discovers and loads context files that shape how it behaves. Some are project-local and discovered from your working directory. SOUL.md is now global to the Hermes instance and is loaded from HERMES_HOME only.
| File | Purpose | Discovery |
|---|---|---|
| .hermes.md / HERMES.md | Project instructions (highest priority) | Walks to git root |
| AGENTS.md | Project instructions, conventions, architecture | CWD at startup + subdirectories progressively |
| CLAUDE.md | Claude Code context files (also detected) | CWD at startup + subdirectories progressively |
| SOUL.md | Global personality and tone customization for this Hermes instance | HERMES_HOME/SOUL.md only |
| .cursorrules | Cursor IDE coding conventions | CWD only |
| .cursor/rules/*.mdc | Cursor IDE rule modules | CWD only |
:::info Priority system
Only one project context type is loaded per session (first match wins): .hermes.md → AGENTS.md → CLAUDE.md → .cursorrules. SOUL.md is always loaded independently as the agent identity (slot #1).
:::
AGENTS.md is the primary project context file. It tells the agent how your project is structured, what conventions to follow, and any special instructions.
At session start, Hermes loads the AGENTS.md from your working directory into the system prompt. As the agent navigates into subdirectories during the session (via read_file, terminal, search_files, etc.), it progressively discovers context files in those directories and injects them into the conversation at the moment they become relevant.
my-project/
├── AGENTS.md ← Loaded at startup (system prompt)
├── frontend/
│ └── AGENTS.md ← Discovered when agent reads frontend/ files
├── backend/
│ └── AGENTS.md ← Discovered when agent reads backend/ files
└── shared/
└── AGENTS.md ← Discovered when agent reads shared/ files
This approach has two advantages over loading everything at startup:
Each subdirectory is checked at most once per session. The discovery also walks up parent directories, so reading backend/src/main.py will discover backend/AGENTS.md even if backend/src/ has no context file of its own.
:::info Subdirectory context files go through the same security scan as startup context files. Malicious files are blocked. :::
# Project Context
This is a Next.js 14 web application with a Python FastAPI backend.
## Architecture
- Frontend: Next.js 14 with App Router in `/frontend`
- Backend: FastAPI in `/backend`, uses SQLAlchemy ORM
- Database: PostgreSQL 16
- Deployment: Docker Compose on a Hetzner VPS
## Conventions
- Use TypeScript strict mode for all frontend code
- Python code follows PEP 8, use type hints everywhere
- All API endpoints return JSON with `{data, error, meta}` shape
- Tests go in `__tests__/` directories (frontend) or `tests/` (backend)
## Important Notes
- Never modify migration files directly — use Alembic commands
- The `.env.local` file has real API keys, don't commit it
- Frontend port is 3000, backend is 8000, DB is 5432
SOUL.md controls the agent's personality, tone, and communication style. See the Personality page for full details.
Location:
~/.hermes/SOUL.md$HERMES_HOME/SOUL.md if you run Hermes with a custom home directoryImportant details:
SOUL.md automatically if one does not exist yetSOUL.md only from HERMES_HOMESOUL.mdSOUL.md is added to the promptHermes is compatible with Cursor IDE's .cursorrules file and .cursor/rules/*.mdc rule modules. If these files exist in your project root and no higher-priority context file (.hermes.md, AGENTS.md, or CLAUDE.md) is found, they're loaded as the project context.
This means your existing Cursor conventions automatically apply when using Hermes.
Context files are loaded by build_context_files_prompt() in agent/prompt_builder.py:
.hermes.md → AGENTS.md → CLAUDE.md → .cursorrules (first match wins)# Project Context headerSubdirectoryHintTracker in agent/subdirectory_hints.py watches tool call arguments for file paths:
path, workdir, shell commands)AGENTS.md, CLAUDE.md, or .cursorrules is found, it's loaded (first match per directory)The final prompt section looks roughly like:
# Project Context
The following project context files have been loaded and should be followed:
## AGENTS.md
[Your AGENTS.md content here]
## .cursorrules
[Your .cursorrules content here]
[Your SOUL.md content here]
Notice that SOUL content is inserted directly, without extra wrapper text.
All context files are scanned for potential prompt injection before being included. The scanner checks for:
<!-- ignore instructions --><div style="display:none">curl ... $API_KEYcat .env, cat credentialsIf any threat pattern is detected, the file is blocked:
[BLOCKED: AGENTS.md contained potential prompt injection (prompt_injection). Content not loaded.]
:::warning This scanner protects against common injection patterns, but it's not a substitute for reviewing context files in shared repositories. Always validate AGENTS.md content in projects you didn't author. :::
| Limit | Value |
|---|---|
| Max chars per file | 20,000 (~7,000 tokens) |
| Head truncation ratio | 70% |
| Tail truncation ratio | 20% |
| Truncation marker | 10% (shows char counts and suggests using file tools) |
When a file exceeds 20,000 characters, the truncation message reads:
[...truncated AGENTS.md: kept 14000+4000 of 25000 chars. Use file tools to read the full file.]
:::tip Best practices for AGENTS.md
## sections for architecture, conventions, important notesFor monorepos, put subdirectory-specific instructions in nested AGENTS.md files:
<!-- frontend/AGENTS.md -->
# Frontend Context
- Use `pnpm` not `npm` for package management
- Components go in `src/components/`, pages in `src/app/`
- Use Tailwind CSS, never inline styles
- Run tests with `pnpm test`
<!-- backend/AGENTS.md -->
# Backend Context
- Use `poetry` for dependency management
- Run the dev server with `poetry run uvicorn main:app --reload`
- All endpoints need OpenAPI docstrings
- Database models are in `models/`, schemas in `schemas/`