Prompt Pipeline
CLI-JAW assembles system prompts through a multi-layer pipeline: static templates (A1/A2), dynamic injection (memory, orchestration, skills), disk caching (B.md/AGENTS.md), and per-CLI spawn adapters.
Assembly Order
The getSystemPrompt() function in src/prompt/builder.ts assembles the prompt in this order:
- A-1.md -- System rules (browser control, memory, heartbeat, delegation)
- A-2.md -- User settings (identity, vibe, working directory)
- Memory injection -- Advanced (profile + soul + task snapshot) or legacy fallback
- Orchestration section -- Employee dispatch rules + PABCD guide
- Heartbeat jobs -- Scheduled task descriptions from
heartbeat.json - Skills section -- Active skills inline + available skill list
- Vision-click hint -- Codex-only legacy fallback for desktop automation
- Delegation rules -- CLI sub-agents vs jaw employees distinction
Static Templates
A-1.md (System Rules)
Path: ~/.cli-jaw/prompts/A-1.md. Falls back to src/prompt/templates/a1-system.md (305 lines). Contains core system behavior: browser control rules, memory/heartbeat instructions, jaw employee vs CLI sub-agent distinctions, and channel send rules.
A-2.md (User Settings)
Path: ~/.cli-jaw/prompts/A-2.md. Template: a2-default.md (25 lines). Contains identity, user preferences, vibe, and working directory hints. Created only if missing -- never overwritten.
Dynamic Injection
Memory Injection
Two paths depending on index readiness:
- Advanced path (
src/memory/injection.ts): Profile context (800 chars) + Soul & Identity (1000 chars) + Task Snapshot (2800 chars, up to 4 hits) - Legacy fallback: Session memory (10000 chars budget) + Core Memory from
MEMORY.md(1500 chars)
Injection is role-aware: boss gets the full snapshot, employee/subagent gets a reduced profile, and flush role gets no memory injection.
Orchestration
If at least one employee is registered, the orchestration.md template is injected with cli-jaw dispatch usage examples. If skills/dev-pabcd/SKILL.md exists, a PABCD Orchestration Guide follows.
Heartbeat
Active heartbeat jobs from ~/.cli-jaw/heartbeat.json are rendered with their enabled state, human-readable schedule, and prompt preview.
Skills
Active skills (~/.cli-jaw/skills/*/SKILL.md) are rendered inline. Reference skills (~/.cli-jaw/skills_ref/registry.json) are listed as available for discovery.
Disk Cache (B.md)
regenerateB() creates a cached version of the system prompt for disk:
| Output | Purpose |
|---|---|
~/.cli-jaw/prompts/B.md | Debug and cache file |
{workDir}/AGENTS.md | Auto-read by Codex, Copilot, OpenCode |
Content hash is checked -- files are only rewritten when the prompt actually changes, preserving resume continuity.
Per-CLI Spawn Input
Each CLI runtime receives the prompt differently:
| CLI | System Prompt | User Input |
|---|---|---|
| Claude | buildArgs(..., sysPrompt) | stdin: withHistoryPrompt(prompt, historyBlock) |
| Codex | AGENTS.md auto-loaded | stdin: [User Message] block |
| Gemini | GEMINI_SYSTEM_MD tmpfile | Args-level prompt |
| AGY | No system prompt flag | agy -p <prompt> |
| Cursor | AGENTS.md / CLAUDE.md auto-loaded | Args-level prompt |
| Grok | CWD instruction files | -p <prompt> |
| Copilot | ACP + cwd instruction files | session/prompt() |
History Block
On new sessions (not resume), buildHistoryBlock() prepends recent conversation context:
- Source:
messagesDB, scoped toworkingDir - Limit: 8000 characters, up to 10 sessions
- Compact markers stop history scanning and insert trace summaries
[Recent Context]
assistant: Previous response summary...
user: Previous question...
---
[Current Message]
Your new prompt here
Customizing Prompts
Edit ~/.cli-jaw/prompts/A-2.md to customize identity, preferences, and working directory. Use /prompt to preview the current A2 content. The Web UI settings panel also provides a prompt template editor.
- 시스템 프롬프트 보여줘
- 프롬프트 커스터마이징 하고 싶어