Rules

Auto-discovered instruction files for agent behavior

The rules command manages auto-discovered instruction files that control agent behavior.

Quick Start

bash
# List all loaded rules
praisonai rules list
List auto-discovered rules example

CLI Auto-Injection

praisonai run, praisonai chat, and bare prompts (praisonai "โ€ฆ", which route to run) automatically load project instruction files from the current directory (and walk up to the git root). Zero config required โ€” drop an AGENTS.md into your project and every modern-engine invocation sees it.

Diagram

CLI Auto-Injection Flow

No

Yes

๐Ÿ’ป praisonai run / chat / bare prompt

๐Ÿ” –no-rules?

๐Ÿ“„ Auto-discover
AGENTS.md, CLAUDE.md,
PRAISON.md, etc.

โญ๏ธ Skip

๐Ÿ’‰ Prepend to prompt

๐Ÿค– LLM

Opt-out

GoalHow
Disable for a single runpraisonai run "task" --no-rules
Disable globallySet [rules] auto = false in ~/.praisonai/config.toml
Override the size capSet [rules] max_chars = 16000 in config.toml
Still load a specific manual rulepraisonai run "task" --include-rules security

Precedence

  1. --no-rules (always wins)
  2. --include-rules <names> (manual list or auto)
  3. [rules] auto in config.toml
  4. Default: auto-loading on

Size caps

CapDefaultWhere to change
Per file12 KB (12000 chars)Hard-coded in RulesManager.MAX_RULE_CHARS
Total32 KB (32000 chars)[rules] max_chars in config.toml

Files over the per-file cap are truncated with a warning. Total context stops at max_chars.

Verbose output

bash
praisonai run "Refactor the auth module" --verbose
# Loaded project instructions: AGENTS.md, CLAUDE.md

Only root-priority files (AGENTS.md, CLAUDE.md, PRAISON.md, GEMINI.md, .cursorrules, .windsurfrules) are listed โ€” modular rules under .praison/rules/ and globals are loaded silently.

Usage

!Manage Auto-Discovered Rules

List Rules

bash
praisonai rules list

Native standalone output โ€” one line per rule (<name> [<activation>] - <description-truncated-to-60-chars>):

PRAISON.md [always] - PraisonAI native project instructions
CLAUDE.md [always] - Claude Code memory file
python-guidelines [glob] - Use type hints and follow PEP 8 across all Pythโ€ฆ

When the workspace has no rules, it prints:

No rules found. Create PRAISON.md, CLAUDE.md, AGENTS.md, or files in .praison/rules/

Wrapper output โ€” the full wrapper renders a Rich panel instead:

โ•ญโ”€ Loaded Rules โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚  ๐Ÿ“œ PRAISON.md (project root)                                               โ”‚
โ”‚  ๐Ÿ“œ CLAUDE.md (project root)                                                โ”‚
โ”‚  ๐Ÿ“œ .cursorrules (project root)                                             โ”‚
โ”‚  ๐Ÿ“œ python-guidelines.md (.praison/rules/)                                  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Add Rule

Native standalone โ€” both <name> and <content> are required. Creates a workspace-scoped rule under .praison/rules/<name>.md with activation="always":

bash
praisonai rules add my_rule "Always use type hints"

Missing content exits 1:

Rule content required. Usage: praisonai rules add <name> <content>

Clear Rules

Native standalone โ€” clears only workspace-scoped rules (those rules add created). Hand-authored AGENTS.md / CLAUDE.md / PRAISON.md, global rules, git-root rules, and nested subdir rules are left untouched:

bash
praisonai rules clear
# Cleared 3 rule(s).

Show Rule Details (wrapper only)

bash
praisonai rules show <rule_name>

Create Rule (wrapper only)

bash
praisonai rules create my_rule "Always use type hints"

On standalone, use praisonai rules add my_rule "Always use type hints" instead.

Delete Rule (wrapper only)

bash
praisonai rules delete my_rule

Show Statistics (wrapper only)

bash
praisonai rules stats

Include Rules with Prompts

bash
praisonai "Task" --include-rules security,testing
praisonai "Task" --no-rules

Declared instruction sources

This page covers auto-discovery โ€” files found by convention (AGENTS.md, CLAUDE.md, .cursorrules, etc.). To declare extra sources explicitly, use the top-level instructions: config key or the praisonai run --instructions flag.

ApproachWhereHow files are chosen
Auto-discovery (this page)Project + git root, walk-upBy convention โ€” drop a known filename and it loads
Declared sourcesinstructions: config / --instructions flagExplicit list of files, globs, or http(s):// URLs

Declared sources load up front alongside the auto-discovered walk-up, and --no-rules suppresses both. See Instruction Sources.

Auto-Discovered Files

PraisonAI automatically discovers instruction files from your project root and git root:

FileDescriptionPriority
PRAISON.mdPraisonAI native instructionsHigh
PRAISON.local.mdLocal overrides (gitignored)Higher
CLAUDE.mdClaude Code memory fileHigh
CLAUDE.local.mdLocal overrides (gitignored)Higher
AGENTS.mdOpenAI Codex CLI instructionsHigh
GEMINI.mdGemini CLI memory fileHigh
.cursorrulesCursor IDE rulesHigh
.windsurfrulesWindsurf IDE rulesHigh
.claude/rules/*.mdClaude Code modular rulesMedium
.windsurf/rules/*.mdWindsurf modular rulesMedium
.cursor/rules/*.mdcCursor modular rulesMedium
.praison/rules/*.mdWorkspace rulesMedium
~/.praisonai/rules/*.mdGlobal modular rulesLow
~/.praisonai/AGENTS.mdGlobal single-file instructions (loaded by load_context_files())Lowest

Rule File Format

Basic Format

markdown
# Guidelines

- Use type hints for all functions
- Follow PEP 8 style guide
- Include docstrings for public methods

With YAML Frontmatter

markdown
---
description: Python coding guidelines
globs: ["**/*.py"]
activation: always  # always, glob, manual, ai_decision
---

# Guidelines

- Use type hints
- Follow PEP 8

@Import Syntax

Reference other files in your rules:

markdown
# CLAUDE.md
See @README for project overview
See @docs/architecture.md for system design
@~/.praisonai/my-preferences.md

How It Works

  1. Discovery: Scans project root and git root for rule files
  2. Priority: Higher priority rules override lower priority
  3. Injection: Rules are injected into agent system prompts
  4. Activation: Rules activate based on globs or manual selection
Diagram

Project Root

Scan Files

PRAISON.md

CLAUDE.md

.cursorrules

.praison/rules/

Merge by Priority

Inject into Agent

Activation Modes

ModeDescription
alwaysRule is always active
globInjected only for files the agent touches during a run โ€” see Path-Scoped Rules in Action
manualOnly active when explicitly included
ai_decisionAI decides when to apply

Programmatic Usage

python
from praisonaiagents import Agent

# Agent auto-discovers CLAUDE.md, AGENTS.md, GEMINI.md, etc.
agent = Agent(name="Assistant", instructions="You are helpful.")
# Rules are injected into system prompt automatically

Best Practices

DoDon’t
Use PRAISON.md for project-wide rulesPut personal prefs in shared files
Use .local.md for personal overridesCommit .local.md files
Use globs for language-specific rulesApply all rules to all files
Keep rules concise and actionableWrite verbose instructions

Related