Book supports customizing the agent’s system prompt through SYSTEM.md files, AGENTS.md files, and CLI flags. This allows you to define custom behaviors, rules, and context that persist across sessions.

Quick Setup with /init

Run /init in the TUI (or start fresh) to bootstrap a project automatically. The wizard:

  1. Detects the project language from root files (build.gradle.kts โ†’ Kotlin, package.json โ†’ TypeScript, Cargo.toml โ†’ Rust, go.mod โ†’ Go, pyproject.toml / requirements.txt โ†’ Python, pom.xml โ†’ Java, etc.)

  2. Creates .bk/SYSTEM.md โ€” a language-appropriate system prompt template with code standards and a project structure placeholder

  3. Creates .bk/tools/ โ€” the directory where you drop .bk.kts extension scripts

  4. Creates AGENTS.md โ€” a project instructions file with the detected build command pre-filled

Edit the generated files to refine Book’s behaviour for your project. If a file already exists, /init skips it and reports โœ“ already exists.

File-Based System Prompts

Book automatically discovers and loads system prompts from:

  1. ~/.bk/SYSTEM.md โ€” Global prompt applied to all sessions

  2. .bk/SYSTEM.md โ€” Project-local prompt for the current directory

These files are merged in order (global first, then local), with each file’s content appended with newline separators.

AGENTS.md โ€” Agent Instructions (per agents.md spec)

Book also automatically loads AGENTS.md files, which follow the community agents.md standard for giving AI agents instructions about a project or user preferences.

Book loads AGENTS.md from:

  1. ~/.bk/AGENTS.md โ€” Global agent instructions applied to all sessions

  2. <projectDir>/AGENTS.md โ€” Project-root agent instructions (the file at the root of your project, not inside .bk/)

Key behaviour: AGENTS.md files are always loaded into context โ€” even when --system-prompt is used to override SYSTEM.md content. This ensures your project’s AI instructions are never silently dropped.

Example: Create a Project AGENTS.md

Place an AGENTS.md at your project root (alongside README.md, build.gradle.kts, etc.):

cat > AGENTS.md << 'EOF'
# Project AI Instructions

## Mandatory Constraints
- MUST use MockK without annotations (no @MockK)
- MUST use AssertK for assertions
- MUST follow TDD red-green-refactor cycle

## Architecture Rules
- Do NOT introduce dependencies between :domain and :infrastructure
- All filesystem access MUST go through SandboxedOkioFileSystem
EOF

Example: Create a Global AGENTS.md

mkdir -p ~/.bk
cat > ~/.bk/AGENTS.md << 'EOF'
# Global Agent Instructions

- Always ask before deleting files
- Prefer Kotlin idiomatic code over Java-style patterns
- Default to functional programming patterns
EOF

Example: Create a Global System Prompt

mkdir -p ~/.bk
cat > ~/.bk/SYSTEM.md << 'EOF'
# My Global Assistant Rules

- Always provide code examples when explaining concepts
- Prefer functional programming patterns in Kotlin
- Keep responses concise (under 3 paragraphs when possible)
EOF

Example: Create a Project-Local System Prompt

mkdir -p .bk
cat > .bk/SYSTEM.md << 'EOF'
# Project Context

This is a Kotlin-based CLI application using Clean Architecture.
When making changes, respect the module boundaries:
- `:domain` โ€” Pure business logic (no framework dependencies)
- `:infrastructure` โ€” Implementations using external libraries
- `:cli` โ€” User interface and DI wiring
EOF

CLI Flags for System Prompts

You can override or append to the file-based prompts using CLI flags.

--system-prompt <file>

Replaces all SYSTEM.md file content with the content from the specified file. AGENTS.md files are still loaded.

echo "You are a helpful code reviewer." > /tmp/reviewer-prompt.md
java -jar "$(ls -t jvm/cli/build/libs/cli-*.jar | grep -vE 'javadoc|sources' | head -1)" --system-prompt /tmp/reviewer-prompt.md "Review this function"

Note: If the specified file is missing or unreadable, Book will fail with an error and exit.

--system-prompt-append <file>

Appends the file content after all SYSTEM.md and AGENTS.md content.

echo "## Additional Context\n- Focus on performance optimization" > /tmp/extra.md
java -jar "$(ls -t jvm/cli/build/libs/cli-*.jar | grep -vE 'javadoc|sources' | head -1)" --system-prompt-append /tmp/extra.md "Optimize this code"

Note: If the specified file is missing or unreadable, Book will fail with an error and exit.

Merge Order & Priority

The final system prompt is constructed in this order:

  1. Base prompt (empty by default)

  2. ~/.bk/SYSTEM.md content (if exists)

  3. .bk/SYSTEM.md content (if exists)

  4. --system-prompt FILE (if provided, replaces steps 2โ€“3; AGENTS.md still loads)

  5. ~/.bk/AGENTS.md content (if exists โ€” always loaded, even with --system-prompt)

  6. <projectDir>/AGENTS.md content (if exists โ€” always loaded, even with --system-prompt)

  7. --system-prompt-append FILE (if provided, appends after all of the above)

  8. Extension BeforeAgentStart hooks (can still modify the final prompt)

Error Handling

  • Auto-discovered files: If ~/.bk/SYSTEM.md, .bk/SYSTEM.md, ~/.bk/AGENTS.md, or <projectDir>/AGENTS.md are missing or unreadable, Book logs a warning and continues (fail-safe).

  • CLI-specified files: If --system-prompt or --system-prompt-append point to a missing or unreadable file, Book prints an error and exits (fail-loud).

Working with Extensions

Extensions registered via .bk.kts scripts can still modify the system prompt through the BeforeAgentStart interceptor. They receive the fully-merged prompt (after all SYSTEM.md files and CLI flags are applied) and can override or append to it.

See the Extension API Guide for details on the BeforeAgentStart interceptor.