Grok Build (Agentic Coding CLI)

Overview

A leaked system prompt for Grok Build, xAI’s terminal-native agentic coding assistant running on Grok 4.5 — the direct xAI counterpart to claude-code-system-prompt, cursor-system-prompt, and cline-system-prompt. The model’s stated role: “You are Grok 4.5 released by xAI. You are an interactive CLI tool that helps users with software engineering tasks.” The user’s request arrives inside a <user_query> tag. The file originates from the asgeirtj/system_prompts_leaks repository alongside grok-personas and grok-expert.

The prompt is structured in three parts: (1) a core behavioral system prompt organized as backtick-wrapped tag blocks, (2) 27 tool definitions with full JSON schemas, and (3) runtime-injected context templates.

Core System Prompt Blocks

The behavioral core uses XML-style tag blocks within a markdown envelope — a lighter cousin of the strict xml-envelope-format:

  • <action_safety> — the risk-tiered confirmation policy, analyzed in action-safety-tiering.
  • <tool_calling> — prefer specialized tools over bash; use dedicated file tools (read_file, search_replace) instead of cat/sed/awk; reserve bash for true system commands; never use bash echo to communicate with the user.
  • <background_tasks> — for watch processes, polling, and CI/log observation, use the monitor tool which streams stdout lines back as chat notifications.
  • <output_efficiency> — write like an excellent technical blog post; complete sentences, high prose quality; plain language over jargon; keep responses proportional to task complexity.
  • <formatting> — GitHub-flavored markdown (CommonMark); use bullets, bold, inline code, and tables actively.
  • <user_guide> — TUI documentation (config, keyboard shortcuts, MCP servers, skills, theming, plugins) is stored as .md files in ~/.grok/docs/user-guide/; the model reads the relevant file when asked about features — documentation-as-files, the same pattern as a skills-directory-gate manifest.

Tool Suite (27 tools)

ToolPurpose
run_terminal_commandBash with timeout (max 36,000,000 ms), background mode, 40,000-char output cap, process-group kill semantics
read_fileRead with line numbers (LINE_NUMBER→CONTENT), offsets/limits, PDF/PPTX/notebook/image support (multimodal)
search_replaceExact-string edit; replace_all for renames; match only content after the prefix
list_dirList files; hides dot-files, respects .gitignore, summarizes large dirs
grepripgrep-backed content search with full regex, glob/type filters, context lines
kill_command_or_subagentTerminate background task/monitor/subagent by task_id
todo_writeLive structured task list with merge-by-id semantics
get_command_or_subagent_outputNon-blocking or blocking retrieval of background results
spawn_subagentSubagents with capability_mode (read-only/read-write/execute/all), git-worktree isolation, resume_from, model allowlist
scheduler_create / scheduler_delete / scheduler_listRecurring tasks; interval grammar (“5m”), max 50, 7-day auto-expire, durable/foreground flags
monitorBackground streaming watch (persistent or timeout-bound), selective filters, grep --line-buffered guidance
search_tool / use_toolMCP tool discovery-then-call loop: search_tool returns input schemas, use_tool calls with qualified server__tool names
workflowRhai-script orchestration of subagents as one background run; agent_budget cap (default 128, max 1,024); validate_only smoke check
enter_plan_mode / exit_plan_modeRead-only plan mode producing an implementation plan file
ask_user_questionMultiple-choice clarification with recommended-first option ordering
web_fetch / web_search / x_searchWeb + X retrieval
image_gen / image_edit / image_to_video / reference_to_videoxAI Imagine generation/editing and video from images (session-relative path references)
writeFile create/overwrite; parent dirs auto-created

Runtime-Injected Context

The prompt defines five injected context templates delivered as system-reminder / wrapper blocks, closely mirroring the architecture this vault itself operates under:

  1. <user_info> + <git_status> — OS/shell/workspace/date snapshot, plus a git status snapshot explicitly marked as not updating during the conversation.
  2. Project instruction files — AGENTS.md-style files injected ordered repo-root → cwd, deeper files taking precedence on conflicts.
  3. Available skills manifest — skill name, description, trigger conditions, and absolute SKILL.md path (the skills-directory-gate pattern).
  4. MCP servers announcement — which servers are connected vs. still connecting; tools from connecting servers are off-limits until announced.
  5. <user_query> wrapper — the user’s message enclosed in a tag.

Implications

Grok Build is the most complete leaked example of a documentation-and-manifest-driven coding agent: the model reads user-guide .md files for TUI features, receives a skills manifest with file paths, and discovers MCP tool schemas before calling them. Its three structural innovations over claude-code-system-prompt-style prompts are the action-safety-tiering confirmation policy, the scheduler/monitor tools for ambient automation, and the Rhai workflow language for bounded subagent orchestration. For the vault, it extends the leaked-agent-prompt family with xAI’s full CLI agent — the missing link between the chat-era Grok persona prompts and the code-era Grok Build product.

Open Questions

  • Is the <action_safety> policy client-side enforced (harness gates tool calls) or purely prompt-level persuasion?
  • Does the Rhai workflow engine ship in production Grok Build, and how does it relate to the subagent capability_mode/isolation machinery?
  • How is ~/.grok/docs/user-guide/ generated, versioned, and kept in sync with the TUI it documents?

Sources