AGENTS.md, CLAUDE.md, .praisonai/rules/*.md) and injects them into every agent run — CLI and direct Agent(...) from Python. Opt out with rules=False when you need a sandboxed / reproducible run.
The user works in a repo with instruction files; the agent discovers them and injects the rules into the system prompt on every run.
How It Works
Supported Instruction Files
PraisonAI automatically loads these files from your project root and git root:| File | Description | Priority |
|---|---|---|
PRAISON.md | PraisonAI native instructions | High (500) |
PRAISON.local.md | Local overrides (gitignored) | Higher (600) |
CLAUDE.md | Claude Code memory file | High (500) |
CLAUDE.local.md | Local overrides (gitignored) | Higher (600) |
AGENTS.md | OpenAI Codex CLI instructions | High (500) |
GEMINI.md | Gemini CLI memory file | High (500) |
.cursorrules | Cursor IDE rules (legacy) | High (500) |
.windsurfrules | Windsurf IDE rules (legacy) | High (500) |
.claude/rules/*.md | Claude Code modular rules | Medium (50) |
.windsurf/rules/*.md | Windsurf modular rules | Medium (50) |
.cursor/rules/*.mdc | Cursor modular rules | Medium (50) |
.praisonai/rules/*.md | Workspace rules | Medium (0) |
~/.praisonai/rules/*.md | Global modular rules | Low (-1000) |
~/.praisonai/AGENTS.md | Global single-file instructions | Lowest (loaded by load_context_files()) |
~/.praisonai/AGENTS.md is the global single-file layer used by load_context_files(). It is separate from the modular ~/.praisonai/rules/*.md files managed by RulesManager and has the lowest precedence — project-level files always override it.Local Override Files:
CLAUDE.local.md and PRAISON.local.md are personal overrides that should be gitignored. They have higher priority than the main files, allowing you to customize rules without affecting the shared project configuration.Quick Start
Opt out: pass
rules=False for sandboxed / reproducible runs where project files must not leak into the prompt.Precedence
rules= climbs the ladder from simplest to most explicit — Bool then RulesConfig — with rules=False as a standalone opt-out.
| You pass | What happens |
|---|---|
Nothing (omit rules=) | Auto-discover and apply if files exist |
rules=None | Same as omitting — auto-discover and apply |
rules=True | Same as above — auto-discover and apply |
rules=RulesConfig(...) | Full control (custom budget / files / workspace) |
rules=False | Off — no discovery, no injection, sandboxed run |
CLI Usage
Project instruction files are auto-injected intopraisonai run, chat, and code — no Python required.
Rule File Format
Rules support YAML frontmatter for advanced configuration:Activation Modes
| Mode | Description | Use Case |
|---|---|---|
always | Always applied (default) | General guidelines |
glob | Applied when file matches pattern | Language-specific rules |
manual | Only via @mention | Security checklists, special procedures |
ai_decision | AI decides when to apply | Context-dependent rules |
Configuration (RulesConfig)
Pass a RulesConfig when you need more than the default zero-config behaviour.
| Option | Type | Default | Description |
|---|---|---|---|
char_budget | Optional[int] | None | Character budget for injected rules context. None = RulesManager default. |
files | Optional[List[str]] | None | Extra instruction file paths / globs registered with high priority beyond auto-discovery. |
workspace_path | Optional[str] | None | Workspace path override. Defaults to os.getcwd(). |
Discovery gate: the first time the agent runs, the workspace is scanned; if no instruction file is found, the RulesManager is dropped and every later run pays zero cost. Extra
files are registered before the gate, so a workspace whose only rules are explicit files=[...] is never dropped. Programmatic equivalent: call RulesManager.add_rule_file(path) — the same machinery RulesConfig(files=[...]) uses under the hood.Choose an option
@Import Syntax (like Claude Code)
Include other files in your rules using the@path/to/file syntax:
Import Depth Limit: Imports are limited to 5 levels deep to prevent circular dependencies. Code spans like
`@org/package` are not treated as imports.Git Root Discovery
PraisonAI automatically discovers rules from the git repository root, enabling monorepo support:load_context_files() (used by configure_host / context_paths) uses the same git-root walk-up and adds layered merge semantics — collecting AGENTS.md, CLAUDE.md, agents.md, and .agents/AGENTS.md at every directory level from ~/.praisonai/AGENTS.md (lowest) up through the git root to cwd (highest). See Context Files → CLI auto-loading for how chat, run, code, and tui automatically inject this context into the agent system prompt.
Monorepos with per-subtree instruction files: see On-demand Subtree Attachment for how a sibling package’s AGENTS.md attaches the moment the agent opens a file inside it.
Storage Structure
Security & Path Safety
Enhanced in PR #1597: MCP
praisonai.rules.* tools now validate rule_name against path traversal attacks.praisonai.rules.show, create, and delete MCP tools validate rule names to prevent path traversal:
Rejected inputs:
- Contains
/,\, or\x00(NUL byte) - Starts with
.(blocks hidden files and..) - Equals
.or.. - The resolved path escapes
~/.praisonai/rules/(symlink-safe)
~/.praisonai/rules/.
Error format: Error: invalid rule_name: '<value>'
Programmatic Rules Management
Creating Rules Programmatically
AI Decision Activation
Forai_decision rules, PraisonAI can use an LLM to decide if a rule should be applied:
Without an LLM function,
ai_decision rules default to being included. This ensures rules are not accidentally skipped.Agent Integration
Rules are auto-applied on every.start() / .chat() / .run() call — no manual wiring needed.
Inspect what was loaded
CLI Integration
Project instruction files are auto-injected intopraisonai run, praisonai chat, and praisonai code runs — no Python required.
CLI flags
| Flag | Effect |
|---|---|
| (default) | Auto-inject all discovered instruction files |
--no-rules | Skip auto-injection for this run |
--include-rules <names> | Force-include named rules (comma-separated) |
--include-rules auto | Explicitly enable auto (same as default) |
--verbose | Print loaded files: Loaded project instructions: AGENTS.md, CLAUDE.md |
Configuration
Global opt-out via~/.praisonai/config.toml:
Cross-Tool Compatibility
PraisonAI rules are compatible with other AI coding assistants:| Tool | File | Compatibility |
|---|---|---|
| Claude Code | CLAUDE.md | ✅ Full |
| Codex CLI | AGENTS.md | ✅ Full |
| Gemini CLI | GEMINI.md | ✅ Full |
| Cursor | .cursorrules, .cursor/rules/*.mdc | ✅ Partial |
| Windsurf | .windsurfrules, .windsurf/rules/*.md | ✅ Partial |
PraisonAI reads the same instruction files used by other AI coding assistants, making it easy to switch between tools while maintaining consistent behavior.
Best Practices
Use PRAISON.md for project-specific rules
Use PRAISON.md for project-specific rules
Create a
PRAISON.md file in your project root with guidelines specific to your project. This file is automatically loaded with high priority.Use glob patterns for language-specific rules
Use glob patterns for language-specific rules
Put language-specific rules in
.praisonai/rules/ with appropriate glob patterns. For example, python.md with globs: ["**/*.py"].Use manual activation for checklists
Use manual activation for checklists
Security checklists, deployment procedures, and other special rules should use
activation: manual and be invoked via @mention when needed.Set appropriate priorities
Set appropriate priorities
Use higher priority (50+) for critical rules that should override others. Default priority is 0 for workspace rules, -1000 for global rules.
Keep rules concise
Keep rules concise
Rules are injected into the system prompt, consuming context window. Keep rules focused and concise to leave room for conversation.
Related
Context Files
CLI auto-loading of AGENTS.md and CLAUDE.md
Hooks
Pre/post operation hooks for custom actions

