Modify the system prompt
The CLI ships with a default system prompt. You have two ways to influence it: append your own guidance on top, or replace it entirely. Append is the right default for most integrations.
Append vs replace
- Append: keep the CLI defaults and add your own coding standards, repo conventions, or persona. Recommended.
- Replace: take full control of the system prompt. Only do this if you have a strong reason; you lose the CLI’s built-in tool guidance, safety rules, and formatting, plus AGENTS.md, stored memory, the skills list and any appended prompt.
Both methods accept either inline text or a file path. The file path mirrors the CLI’s --sys-prompt / --append-system-prompt flags.
Append to the default prompt
Use this for repo-specific rules, brand voice, or workflow guardrails.
import { AutohandSDK } from '@autohandai/agent-sdk';
const sdk = new AutohandSDK({ cwd: '.' })
.appendSystemPrompt(
"Always run bun run typecheck before declaring a fix complete."
);
await sdk.start();from autohand_sdk import AutohandSDK
sdk = AutohandSDK(
cwd=".",
append_system_prompt="Always run uv run pytest before declaring a fix complete.",
)
await sdk.start()sdk := autohand.NewSDK(&autohand.Config{
CWD: ".",
AppendSystemPrompt: "Always run go test ./... before declaring a fix complete.",
})
_ = sdk.Start(ctx)AutohandSDK sdk = new AutohandSDK(SDKConfig.builder()
.cwd(".")
.appendSystemPrompt("Always run mvn test before declaring a fix complete.")
.build());
sdk.start();let agent = Agent(
name: "Reviewer",
instructions: "Always run swift test before declaring a fix complete.",
tools: [.readFile, .bash],
model: ModelID("gpt-4o"),
provider: OpenAIProvider(apiKey: "sk-...")
)The TypeScript and Python SDKs also accept a file path. The SDK passes the value to the CLI, which treats a single-line value as a path when it starts with ./, ../, / or ~/, ends with .md, .txt or .prompt, or contains a slash and no spaces. Relative paths resolve from the workspace root. If no file exists at that path, the value is sent as literal prompt text with no error, so a misspelled path becomes a one-line prompt. See File path detection.
const sdk = new AutohandSDK({ cwd: '.' })
.appendSystemPrompt('./prompts/release-readiness.md');sdk = AutohandSDK(
cwd=".",
append_system_prompt="./prompts/release-readiness.md",
)Replace the default prompt
Use this only when you need to fully define the agent’s behaviour. The replacement is the entire system prompt: AGENTS.md, stored memory, the skills list and any appended prompt (including instructions) are not added. You are responsible for tool guidance, safety rules, and output formatting.
import { AutohandSDK } from '@autohandai/agent-sdk';
const sdk = new AutohandSDK({ cwd: '.' })
.setSystemPrompt('./SYSTEM_PROMPT.md');
await sdk.start();from autohand_sdk import AutohandSDK
sdk = AutohandSDK(
cwd=".",
system_prompt="./SYSTEM_PROMPT.md",
)
await sdk.start()sdk := autohand.NewSDK(&autohand.Config{
CWD: ".",
SystemPrompt: "./SYSTEM_PROMPT.md",
})AutohandSDK sdk = new AutohandSDK(SDKConfig.builder()
.cwd(".")
.systemPrompt("./SYSTEM_PROMPT.md")
.build());Per-agent instructions
The high-level Agent.create() API takes an instructions field that becomes part of the appended prompt, so it has no effect when you also replace the prompt. In the TypeScript SDK, combining instructions with a file path in the append option joins them into inline text, so the file is not read. Use this for short-lived agents that need a focused persona.
import { Agent } from '@autohandai/agent-sdk';
const agent = await Agent.create({
cwd: '.',
instructions: 'You review code with Staff-level TypeScript judgement. Prefer Bun.',
});
const result = await agent.run('Review the changes in src/auth/');# The Python SDK uses append_system_prompt directly.
sdk = AutohandSDK(
cwd=".",
append_system_prompt="You review code with Staff-level Python judgement. Prefer uv.",
)agent, _ := autohand.NewAgent(ctx, &autohand.Config{
CWD: ".",
AppendSystemPrompt: "You review code with Staff-level Go judgement.",
})Agent agent = Agent.create(AgentOptions.builder()
.cwd(".")
.instructions("You review code with Staff-level Java judgement.")
.build());Best practices
- Default to appending. Replacing is rarely the right answer.
- Keep prompts in files under version control. Put them next to the code they govern.
- Be specific about success criteria (“tests pass”, “file compiles”) so the agent knows when it can stop.
- State what the agent should not do. “Do not edit migration files” is more useful than a long list of allowed paths.
- If you maintain multiple agents, keep the default prompt and append per-agent overrides on top. Appended text is dropped when you replace the prompt, so a replacement must contain everything.