Init

Scaffold the .praisonai/ project convention in one command

praisonai init creates a working .praisonai/ project — config, a starter agent, a starter command, and a starter tool — so the next commands you type already run.

Diagram

praisonai init

–generate

⚡ praisonai init

📁 .praisonai/

📝 config.yaml

🤖 agents/assistant.md

🛠 commands/review.md

🔧 tools/example.py

🧠 Analysis Agent

📄 AGENTS.md at repo root

Quick Start

  1. Scaffold the project
    bash
    praisonai init

    This writes four files under .praisonai/ — skipping any that already exist.

  2. Run the scaffolded agent
    bash
    praisonai run --agent assistant "hello"
  3. Run the scaffolded command
    bash
    praisonai run --command review "src/foo.py"

How It Works

Diagram
File systempraisonai initUserFile systempraisonai initUserpraisonai initResolve target (git root or cwd)Write config.yaml / agents/ / commands/ / tools/Created / Skipped per fileNext-step commands
StepWhat happens
Resolve targetWalks up to the git root (or uses cwd) and sets .praisonai/ as the base
Write filesCreates config.yaml, agents/assistant.md, commands/review.md, tools/example.py
ReportPrints Created <path> or Skipped (already exists, use --force): <path> per file
Next stepsPrints the exact praisonai run --agent and praisonai run --command commands you can copy, plus a one-line hint that project-local tools are opt-in

Project vs global

Diagram

Share with the team via git

Personal across all projects

Where should agents/commands live?

praisonai init

praisonai init –global

./.praisonai/

~/.praisonai/

Flags

FlagTypeDefaultDescription
--globalboolFalseScaffold the user-global ~/.praisonai/ instead of the project directory
--force / -fboolFalseOverwrite existing files (otherwise existing files are skipped)
--generate / -gboolFalseAnalyse the repo and generate a tailored AGENTS.md at the repo root using the scaffolded model. Requires a provider credential; falls back silently to the static scaffold when no credential is present or generation fails. Respects --force on an existing AGENTS.md.

Scaffolded files

Scaffolded model is provider-aware

praisonai init reads your available provider credentials (OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, GOOGLE_API_KEY, GROQ_API_KEY, COHERE_API_KEY, OLLAMA_HOST) and writes the matching default model into both config.yaml and agents/assistant.md. Falls back to gpt-4o-mini when no credential is detected. This choice is not persisted as your recent model — subsequent praisonai run invocations resolve independently.

See Models → Provider Auto-Detection for the full credential-to-model precedence table.

config.yaml — project-wide defaults:

yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/MervinPraison/PraisonAI/main/src/praisonai/praisonai/cli/configuration/config.schema.json
# PraisonAI project configuration
# Defaults applied to scaffolded agents and commands.
# Sections are nested exactly as the resolver consumes them.
agent:
  model: gpt-4o-mini
output:
  format: text

The # yaml-language-server: line enables editor autocomplete and inline error highlighting in VS Code (YAML extension) and other LSP-aware editors. The nested agent: / output: shape is exactly what ConfigResolver reads — flat top-level model: / output: keys will now produce a warning.

agents.yaml editor header

Any scaffold path that emits an agents.yaml now prepends a matching header so editors validate agent definitions immediately — no manual setup.

yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/MervinPraison/PraisonAI/main/src/praisonai/praisonai/config/agents.schema.json

The header is a plain YAML comment, so runtime parsing is unaffected. See Editor Support for full setup across VS Code, Neovim, and JetBrains IDEs.

agents/assistant.md — ready-to-run starter agent:

markdown
---
model: gpt-4o-mini
role: Assistant
goal: Help the user accomplish tasks accurately and concisely
instructions: |
  You are a helpful assistant. Answer clearly and concisely.
  When you are unsure, say so instead of guessing.
---
You are a helpful assistant for this project.

Be concise, accurate, and practical. Prefer actionable answers.

commands/review.md — starter command using $ARGUMENTS and @file:

markdown
---
description: Review the provided code or file and suggest improvements
---
Review the following and suggest concrete improvements
(correctness, readability, performance, and security):

$ARGUMENTS

If a file path is provided, here are its contents:

@$ARGUMENTS

tools/example.py — commented @tool starter, auto-discovered on run:

python
"""Project-local tools for this .praisonai/ project.

Every public callable in this directory is made available to the agent on
`praisonai run` — no --tools flag required. Decorate a function with @tool for
a rich schema, or just define a plain function.

Loading executes this file, so it is OPT-IN. Enable it on `run` with either:

    praisonai run --allow-local-tools "use the greet tool to greet Ada"
    # or: export PRAISONAI_ALLOW_LOCAL_TOOLS=true

Without the opt-in, `run` prints a one-line hint (it never silently skips).
Uncomment the example below to try it.
"""

# from praisonaiagents import tool
#
#
# @tool
# def greet(name: str) -> str:
#     """Return a friendly greeting for the given name."""
#     return f"Hello, {name}!"

Uncomment the stub and pass --allow-local-tools (or set PRAISONAI_ALLOW_LOCAL_TOOLS=true), then every praisonai run in this project auto-loads example.greet. See Project-local tools for discovery and safety rules.

AGENTS.md generation (–generate)

praisonai init --generate runs a short analysis agent that reads a cheap snapshot of your repo and writes a tailored AGENTS.md at the repo root — so your next praisonai run starts with real project context instead of boilerplate.

bash
# One command — scaffold + tailored AGENTS.md
praisonai init --generate

# Regenerate later after big refactors
praisonai init --generate --force
Diagram
Repo rootAnalysis AgentPre-scanpraisonai init -gUserRepo rootAnalysis AgentPre-scanpraisonai init -gUseralt[Generation succeeds][Generation fails]alt[No provider credential][Credential present]praisonai init –generateWrite static .praisonai/ scaffoldWarning — kept static scaffoldSnapshot tree + manifests + README headagent.run(prompt)Tailored markdownWrite AGENTS.md at repo rootGenerated AGENTS.mdExceptionWarning — kept static scaffold
BehaviourDetail
Credential requiredRuns only when OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY/GOOGLE_API_KEY, GROQ_API_KEY, COHERE_API_KEY, or OLLAMA_HOST is set
Model usedThe same provider-aware scaffold_model written into config.yaml / assistant.md
Output locationAlways the repo root (git root or cwd) — never ~/AGENTS.md, even with --global
Non-destructiveAn existing AGENTS.md is skipped with a warning unless --force is also passed
Graceful fallbackNo credential or generation error → keeps the static scaffold, writes no file, exits 0

How the agent sees your repo

The pre-scan is deliberately small so cost and tokens stay bounded:

  • Top-level entries — directories first, first 60 names.
  • Detected manifests — pyproject.toml, setup.py, setup.cfg, requirements.txt, package.json, Cargo.toml, go.mod, pom.xml, build.gradle, Makefile, Dockerfile, docker-compose.yml, tox.ini.
  • README head — first 1500 characters of README.md, README.rst, README.txt, or README (first match wins).

Common Patterns

Scaffold a fresh project

bash
praisonai init
praisonai run --agent assistant "hello"

Re-init after editing a file

praisonai init is idempotent — it skips files that already exist. To overwrite with the original starters:

bash
praisonai init --force

Set up personal shortcuts

bash
praisonai init --global

Agents and commands land in ~/.praisonai/ and are available in every project. Project-level definitions override global ones on name collision.

Generate a repo-tailored AGENTS.md

bash
praisonai init --generate

Scaffolds .praisonai/ and writes a project-specific AGENTS.md the rules loader picks up automatically. Regenerate after major changes:

bash
praisonai init --generate --force

Best Practices

Commit .praisonai/ to git

Check in .praisonai/agents/, .praisonai/commands/, and .praisonai/tools/ so the whole team shares the same agents, commands, and tools without any extra setup. Project-local tools still require each teammate to pass --allow-local-tools (or set PRAISONAI_ALLOW_LOCAL_TOOLS=true) before they auto-load.

PraisonAI also discovers agents and commands from existing .claude/agents/ / .claude/commands/ and .agents/agents/ / .agents/commands/ layouts, so teams that already keep definitions for another tool don’t have to copy them into .praisonai/. See Custom Agents & Commands.

Keep ~/.praisonai/ personal

Use --global for shortcuts that are specific to you. Team-shared agents belong in the project directory — project files override global on name collision.

Edit the starter files, don't replace them

The scaffolded files match the exact shape CustomDefinitionsDiscovery parses: frontmatter fields for agents, $ARGUMENTS / @file substitutions for commands. Keep that structure when customising.

Use –force carefully

--force overwrites existing files without prompting. Commit or back up your edits first.

Prefer –generate for real projects

The tailored AGENTS.md gives agents the specific build/test/run commands and conventions on first contact — which is what the rules loader ships to every subsequent turn. Keep the flag off for empty scaffolds and demos.

Related