Skip to content

Why Composable Prompts

Your agent config file is 400 lines. Half is voice and tone. A quarter is project rules. The rest is workflow instructions. It all lives in one file.

This works until it doesn’t. Three things break:

No reuse. You copy the file between projects. You tweak it for each one. The copies drift. Six months later you have five versions and no source of truth.

No switching. You want the agent to do code review instead of writing code. You rewrite the file, or you maintain two files by hand and swap them. Neither scales.

No sharing. A teammate asks how you set up your agent. You paste a blob into Slack. They paste it into their config. No structure, no versioning, no way to push an update.

The monolithic file is a dead end. It conflates identity, workflow, and constraints into one unstructured blob. Every change is a full-file edit. Every variant is a fork.

The most advanced AI agent systems don’t use monolithic prompts. They assemble prompts from modular, composable sections at runtime:

  • Cached identity sections — who the agent is, how it behaves. Stable across sessions. Loaded once and reused.
  • Dynamic task sections — current context, active tools, user-specific state. Changes every turn or every session.
  • Behavioral constraints — guardrails applied conditionally based on context, project, or task type.

This isn’t a niche pattern. Production coding agents, research assistants, and autonomous workflows all converge on the same structure. The prompt is not a single document — it’s an assembly of layers, each with its own lifecycle and ownership.

Why does this work? Because each section has a different rate of change. Identity is nearly static. Task context changes every request. Constraints change per project or deployment. Bundling them together means reprocessing stable content every time dynamic content changes. Separating them lets each layer be cached, tested, and updated independently.

The industry is converging on composable prompt architectures. The question is whether you manage that composition by hand or with tooling.

Software engineers already know this principle: separate things that change for different reasons. The same logic applies to prompt configuration.

Three natural seams emerge:

LayerMaps toChanges when
SoulIdentity — voice, character, standardsRarely. Reflects who the agent is.
PersonaRole — workflow, methodology, toolsPer task. Reflects what the agent is doing.
RulesConstraints — guardrails, policiesPer project or context. Reflects what the agent must not do.

These aren’t arbitrary divisions. They map to how behavior naturally decomposes:

  • Who you are doesn’t change when you switch tasks.
  • What you’re doing doesn’t change your core character.
  • What you must not do depends on the project, not the persona.

A monolithic file manages all three in one blob. When you change the voice, you risk breaking a guardrail. When you add a project rule, you’re editing the same file that defines workflow. When you want to share just the guardrails with a teammate, you can’t — they’re tangled into everything else.

Composable layers let you change one concern without touching the others. Update the voice across every project by editing one soul. Swap the workflow by switching one persona. Add a security constraint without reading 400 lines of unrelated config.

Instant context switching. One command swaps the full agent configuration:

Terminal window
brainjar brain use review

No file editing. No copy-paste. The agent is now a reviewer with the right persona, voice, and rules. See Brains.

Team alignment. Export a brain as a pack. Teammates import it. The entire team runs the same agent behavior for the same workflow:

Terminal window
brainjar pack export review --author yourname
brainjar pack import ./review --activate

One pack, version-controlled, shareable. See Packs.

Subagent orchestration. Compose a full prompt from named layers and dispatch it to a subagent. The lead agent doesn’t paste raw text — it assembles a prompt from components via the MCP tool:

mcp__brainjar__compose(brain="review", task="Review changes in src/sync.ts")

The returned prompt is passed to Claude Code’s Agent tool to spawn the subagent. Each worker gets exactly the identity, role, and constraints it needs — with worktree isolation available for parallel dispatch. See Subagent Orchestration.

Reproducibility. Save a configuration, restore it anywhere. Same layers in, same behavior out. No drift, no “works on my machine” for agent setups. Debug a misbehaving agent by inspecting each layer independently — you can see exactly which layer introduced a behavior.

brainjar treats prompt configuration as a first-class engineering artifact. Souls, personas, and rules are version-controlled markdown documents. They compose into brains. Brains compose into full prompts. The CLI drives the workflow; the server holds the state.

The result: agent behavior that’s modular, shareable, and reproducible — managed with the same rigor you’d apply to code.

Start with Getting Started or learn about the core concepts.