cli-agent-runner
Use this skill when you need to invoke another Claude Code session via the cli-agent-runner.sh script to perform specialized, potentially long-running tasks in a simplified way. This wrapper handles session management, result extraction, and can be run in background with polling support.
What this skill does
# CLI Agent Runner Skill ## Intro This skill provides guidance on using the `cli-agent-runner.sh` script to delegate work to Claude Code sessions. Use this when you need to: - Delegate a task to a specialized session for long-running operations - Resume tasks later using a simple session name (no session ID management needed) - Run sessions in the background with polling support - Get clean result output without manual JSON parsing - Optionally use agent definitions for specialized behavior **Key Benefits:** - Session names instead of session IDs (simpler to track and resume) - Automatic session file management in `.cli-agent-runner/agent-sessions/` directory - Built-in result extraction (no need for head/tail/jq commands) - Clean output to stdout, errors to stderr - Optional agent associations for specialized capabilities ## Terminology - **Session**: A named, running conversation with Claude Code - **Agent**: A reusable configuration/definition that provides specialized behavior for sessions - **Session Name**: The unique identifier you give to a conversation (e.g., `architect`, `reviewer`) - **Agent Name**: The identifier for a reusable agent definition (e.g., `system-architect`, `security-reviewer`) ## Variables The following variables are used in the commands and instructions: - `<session-name>`: A unique identifier for the session (alphanumeric, dash, underscore only; max 30 chars) - `<agent-name>`: Optional agent definition to use for the session - `<initial-prompt>`: The prompt or task description for a new session - `<resume-prompt>`: The prompt or task description to continue an existing session's work - `<POLL_INTERVAL>`: The interval in seconds to wait between polling attempts. Default is 60 seconds. ## Script Location **IMPORTANT:** The `cli-agent-runner.sh` script is located in the same directory as this SKILL.md file. So it is in the root folder of the skill plugin. Before using the script for the first time in a conversation, you MUST locate it: 1. Identify the root folder of the plugin skill and append the script name: ``` <path-to-skill-root-folder>/cli-agent-runner.sh ``` 2. Store this path mentally for the rest of the conversation: <absolute-path-to-cli-agent-runner.sh> 3. Use the absolute path in all subsequent commands **Example:** ```bash # Use that exact path in all commands: <absolute-path-to-cli-agent-runner.sh> new <session-name> -p "<prompt>" ``` **Note:** In all examples below, `cli-agent-runner.sh` represents the absolute path <absolute-path-to-cli-agent-runner.sh> you discovered. Replace it with the actual path when executing commands. ## Commands Overview The cli-agent-runner.sh supports five commands: 1. **new** - Create a new session (optionally with an agent) 2. **resume** - Resume an existing session by name 3. **list** - List all sessions with their session IDs 4. **list-agents** - List all available agent definitions 5. **clean** - Remove all sessions ## Usage Patterns ### Pattern 1: Synchronous Execution (Wait for Completion) Use this when you want to wait for the session to complete and get the result immediately. **Creating a new session:** ```bash ./cli-agent-runner.sh new <session-name> -p "<initial-prompt>" ``` **Creating a new session with an agent:** ```bash ./cli-agent-runner.sh new <session-name> --agent <agent-name> -p "<initial-prompt>" ``` **Creating a new session with prompt from file/stdin:** This should be considered when the prompt is large or complex or already a prompt file exists potentially created by another session. ```bash cat prompt.md | ./cli-agent-runner.sh new <session-name> ``` **Resuming an existing session:** ```bash ./cli-agent-runner.sh resume <session-name> -p "<resume-prompt>" ``` **Example:** ```bash # Create new session with agent ./cli-agent-runner.sh new architect --agent system-architect -p "Create a high-level architecture document for a user authentication system" # The script blocks until completion and outputs the result # Output: <result from session> # Resume the session later (agent association is remembered) ./cli-agent-runner.sh resume architect -p "Add API endpoint specifications to the architecture" ``` ### Pattern 2: Background Execution with Polling Use this when you want to start the session in the background and poll for completion. **Instructions:** **1. Start the session in the background:** - Use Bash tool with `run_in_background: true` - Use either `new` or `resume` command - **Important:** Note the bash_id returned by the Bash tool **Example for new session:** ```bash ./cli-agent-runner.sh new <session-name> -p "<initial-prompt>" ``` **Example for new session with agent:** ```bash ./cli-agent-runner.sh new <session-name> --agent <agent-name> -p "<initial-prompt>" ``` **Example for resuming session:** ```bash ./cli-agent-runner.sh resume <session-name> -p "<resume-prompt>" ``` **2. Initial Polling Wait:** - Use Bash tool (NOT background): `sleep <POLL_INTERVAL>` - Default POLL_INTERVAL is 60 seconds **3. Check if background process is still running:** - Use BashOutput tool with the bash_id from step 1 - The tool returns shell status showing if process is running or completed - If status shows still running: continue to step 4 - If status shows completed: continue to step 5 - **Do NOT use:** kill -0, pgrep, ps, or any other process checking commands **4. Polling Wait Loop:** - Use Bash tool (NOT background): `sleep <POLL_INTERVAL>` - Return to step 3 **5. Process Completed - Get Results:** - The result is already captured in the Bash tool's output when the process completes - Simply read the output from the completed Bash execution - The output will be the session's result (already extracted by the script) **Full Background Example:** ```bash # Step 1: Start in background ./cli-agent-runner.sh new architect --agent system-architect -p "Design authentication system" # Returns bash_id: abc123 # Step 2: Initial wait sleep 60 # Step 3: Check status # Use BashOutput with bash_id: abc123 # If status: running, continue to step 4 # If status: completed, read the output - it contains the result # Step 4: If still running, wait and check again sleep 60 # Return to step 3 ``` ### Pattern 3: Listing Sessions Use this to see all existing sessions and their status. ```bash ./cli-agent-runner.sh list ``` **Output format:** ``` session-name (session: session-id) architect (session: 3db5dca9-6829-4cb7-a645-c64dbd98244d) reviewer (session: initializing) ``` - "initializing" means the session file exists but hasn't started yet (empty file) - "unknown" means the session ID couldn't be extracted - Otherwise, shows the actual session ID ### Pattern 4: Listing Available Agent Definitions Use this to discover what agent definitions are available before creating a session. ```bash ./cli-agent-runner.sh list-agents ``` **Output format:** ``` agent-name: description --- next-agent-name: description --- another-agent-name: description ``` **Example output:** ``` code-reviewer: Reviews code for best practices, bugs, and potential improvements --- documentation-writer: Creates comprehensive technical documentation and guides --- system-architect: Expert in designing scalable system architectures ``` **Use Case:** - Discover available agents before creating a new session - Understand what specialized capabilities are available - Choose the appropriate agent for your task **Important Notes:** - Each agent definition is separated by `---` for clear parsing - Agent names can be used with `--agent` flag when creating sessions - If no agents exist, outputs: "No agent definitions found" ### Pattern 5: Cleaning All Sessions Use this to remove all sessions and start fresh. ```bash ./cli-agent-runner.sh clean ``` **Behavior:** - Removes the entire `.cli-agent-runner/agent-sessions/` directory - All session files and history are permanently deleted - No confirmation prompt - immediate deletion - Safe to run even if n
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.