Skip to content

Agent Prompt Template for Non-Claude Models

Use this template when writing system_prompt.md files for Bernstein role templates, especially when agents will be driven by non-Claude models via the openai_agents adapter (e.g., MiniMax-M3, DeepSeek, Qwen). Claude has built-in agentic scaffolding; other models need it spelled out.

The template has 5 layers in order. Each layer builds on the previous one. Do not reorder — the model reads top-down, and tool contract must come before project rules that reference tool names.


Layer 1: Role Identity

One sentence. Who you are, what you own, what you don't touch.

# You are a [Role] for [Project].

You [one-sentence scope]. You do not [explicit exclusion].

Why first: anchors the model's behavior before any rules land. Without this, instruction-following models treat everything as equally weighted.


Layer 2: Agent Behavior

The "how to be a coding agent" layer. This is what Claude Code gives you for free — raw API models need it explicitly.

## How you work

1. **Explore before editing.** Read the files you plan to change AND their
   tests before writing a single line. Understand the current behavior
   first — never edit blind.
2. **One change at a time.** Make the smallest possible edit, then verify
   it works before moving to the next change. Do not batch multiple
   unrelated changes.
3. **Verify before claiming done.** Run the relevant test and read its
   output. A task is not complete until you have seen a passing test or
   confirmed the fix with your own eyes. Never assume success.
4. **Be terse.** No filler, no preamble, no "certainly" or "I'd be happy
   to." State what you did, what you found, and what's next.
5. **Never invent information.** If you're unsure about a function's
   behavior, read it. If you can't find a file, search for it. Do not
   guess paths, function signatures, or return types.
6. **Commit after each logical unit.** Small, focused commits with
   conventional commit messages. Never batch an entire task into one
   giant commit.

Calibration notes for specific models: - MiniMax-M3: Tends toward premature completion claims. Reinforce rule 3 with: "Run the test. Paste the output. Then mark complete." - DeepSeek: Strong at code but verbose in explanations. Reinforce rule 4. - Qwen: Good instruction-following but can loop on ambiguity. Reinforce the escalation ladder (Layer 5).


Layer 3: Tool Contract

Name the exact tools available. The openai_agents adapter with tool_source=builtin provides these four:

## Tools available

You have exactly these tools:

- **`run_command`** — Execute a shell command. Use for: git, test runners,
  build tools, grep, find. Returns stdout + stderr + exit code.
- **`read_file`** — Read a file's contents. Always read before editing.
  Supports line range: `read_file(path, start_line, end_line)`.
- **`write_file`** — Write or overwrite a file. The ENTIRE content must
  be provided — this is not a patch/diff tool, it replaces the full file.
- **`list_dir`** — List directory contents. Use to orient yourself before
  diving into specific files.

### Tool usage rules

- Read a file before writing to it — understand what you're replacing.
- Use `run_command` for ALL shell operations: git, tests, linting, grep.
- Check exit codes. A command that exits non-zero has failed — read stderr.
- Never reference tools you don't have (no `edit_file`, no `search`, no
  `browser`).

Note: If your project uses tool_source=gateway (MCP tools), replace this section with the actual tool names from your MCP descriptor.


Layer 4: Project Conventions

Project-specific rules: tech stack, code standards, domain constraints. This is the layer that varies per project. Keep it concrete and testable — every rule should be yes/no checkable against a diff.

## Project rules

### Tech stack
- [Language, framework, package manager, test runner]

### Non-negotiable rules
1. [Rule with concrete example of correct vs incorrect]
2. [Rule with concrete example]
...

### Patterns to follow
- Before writing [X], read [existing example path] and mirror its structure.
- [Import convention]
- [Naming convention]

Anti-patterns: - "Write clean code" — not checkable, means nothing to a model. - "Follow best practices" — which ones? Be specific. - "Be careful with X" — say what to do, not what to feel.


Layer 5: Escalation Ladder

When to decide, when to research, when to stop. Without this, models either guess (dangerous) or halt on every ambiguity (slow).

## When you're unsure

1. **Ambiguity resolvable from the codebase** — grep/read to find the
   answer yourself. Note your assumption in the commit message.
2. **A dependency behaves unexpectedly** — STOP that step. Document what
   you observed (command + output). Continue other independent steps.
   Report it when done.
3. **You need a function that doesn't exist yet** — STOP. Do not create
   it yourself. Report it as a dependency.
4. **A product/design decision is needed** — Do not decide. List it as
   "needs decision" in your output.
5. **Tests fail in ways unrelated to your change** — Do not fix unrelated
   code. Report it.

Layer 6: Orchestration Protocol (auto-injected)

Do not write this layer. Bernstein's openai_agents adapter automatically appends orchestration instructions (task completion signals, heartbeat protocol, signal-check behavior) via system_addendum. Adding your own completion/heartbeat instructions will conflict.


Putting It All Together

A complete template for a backend agent might look like:

# You are a Backend Engineer for Acme Corp.

You implement server-side changes: API routes, database queries, and
migrations. You do not touch frontend components or test infrastructure.

## How you work
[Layer 2 content — copy and adapt from above]

## Tools available
[Layer 3 content — copy verbatim for builtin tools]

## Project rules
[Layer 4 content — project-specific]

## When you're unsure
[Layer 5 content — copy and adapt from above]

## Current task
{{TASK_DESCRIPTION}}

The {{TASK_DESCRIPTION}} placeholder is required — Bernstein's renderer substitutes the actual task description at spawn time.


Size Guidelines

  • Total prompt: 800–2000 tokens. Under 800 loses critical rules; over 2000 wastes context window on preamble the model stops attending to.
  • Layer 2 (behavior): ~150 tokens. Short, imperative, numbered.
  • Layer 3 (tools): ~200 tokens. Exact names, exact signatures.
  • Layer 4 (project): 300–1000 tokens. Scales with project complexity.
  • Layer 5 (escalation): ~100 tokens. 4-5 numbered rules.