coding-agent
Run Codex CLI, Claude Code, or other coding agents as background processes for programmatic control. Use when a user asks to run a coding agent, delegate a task to another AI, spawn a sub-agent, run Claude Code in the background, or orchestrate multiple coding agents on separate tasks.
What this skill does
# Coding Agent ## Overview Run coding agents (Claude Code, Codex CLI, Gemini CLI, or others) as background processes for programmatic task delegation. Spawn sub-agents to handle well-scoped tasks, monitor their progress, and collect results. Useful for parallel task execution, complex multi-step workflows, and automated coding pipelines. ## Instructions When a user asks you to delegate work to a coding agent or run one in the background, follow this process: ### Step 1: Verify the agent CLI is available Check which coding agent CLIs are installed: ```bash # Check for Claude Code claude --version 2>/dev/null && echo "claude available" || echo "claude not found" # Check for Codex CLI codex --version 2>/dev/null && echo "codex available" || echo "codex not found" # Check for Gemini CLI gemini --version 2>/dev/null && echo "gemini available" || echo "gemini not found" ``` If none are available, instruct the user to install one: ```bash # Claude Code npm install -g @anthropic-ai/claude-code # Codex CLI npm install -g @openai/codex ``` ### Step 2: Define the task clearly Before spawning an agent, ensure the task is: - **Well-scoped:** A single, clear objective (not "fix everything") - **Self-contained:** The agent can complete it without interactive input - **Verifiable:** You can check the output or result when done Write a clear prompt that includes: - What to do (specific action) - Where to do it (file paths, directories) - Constraints (do not modify other files, follow conventions) - Expected output format ### Step 3: Run the agent **Claude Code (background, non-interactive):** ```bash # Run with a specific prompt, print-only mode claude -p "Refactor the function parseConfig in src/config.ts to use zod validation. Do not modify other files." \ --output-format text \ 2>&1 | tee /tmp/agent-output.txt & # Store the PID for monitoring AGENT_PID=$! echo "Agent running with PID: $AGENT_PID" ``` **Claude Code with specific options:** ```bash # Limit scope and disable interactive features claude -p "Add JSDoc comments to all exported functions in src/utils/" \ --no-permissions \ --output-format json \ > /tmp/agent-result.json 2>&1 & ``` **Codex CLI:** ```bash codex --prompt "Write unit tests for src/auth/login.ts covering success, failure, and timeout cases" \ --auto-approve \ 2>&1 | tee /tmp/codex-output.txt & ``` ### Step 4: Monitor and collect results ```bash # Check if the agent is still running ps -p $AGENT_PID > /dev/null 2>&1 && echo "Still running" || echo "Finished" # Wait for completion wait $AGENT_PID EXIT_CODE=$? echo "Agent exited with code: $EXIT_CODE" # Read the output cat /tmp/agent-output.txt ``` ### Step 5: Validate the results After the agent finishes: - Check the exit code (0 = success) - Review the output for errors or warnings - Verify the changes by reading modified files - Run any relevant tests to confirm correctness - Report the results to the user ## Examples ### Example 1: Delegate test writing to a background agent **User request:** "Write tests for the auth module while I work on the API" **Actions:** ```bash # Spawn Claude Code to write tests in the background claude -p "Write comprehensive unit tests for all functions in src/auth/. \ Use vitest as the test framework. Create test files next to source files \ with .test.ts extension. Cover success, failure, and edge cases. \ Do not modify any source files." \ --output-format text \ 2>&1 | tee /tmp/test-agent.txt & TEST_PID=$! echo "Test writing agent started (PID: $TEST_PID)" ``` After completion, review the generated test files and run the test suite: ```bash wait $TEST_PID npx vitest run src/auth/ ``` ### Example 2: Run parallel agents for independent tasks **User request:** "Add types to the utils folder and add docs to the components folder" **Actions:** ```bash # Agent 1: Add TypeScript types claude -p "Add strict TypeScript types to all functions in src/utils/. \ Replace any 'any' types with proper types. Do not modify files outside src/utils/." \ --output-format text > /tmp/types-agent.txt 2>&1 & PID1=$! # Agent 2: Add documentation claude -p "Add JSDoc documentation to all React components in src/components/. \ Include @param, @returns, and @example tags. Do not modify logic." \ --output-format text > /tmp/docs-agent.txt 2>&1 & PID2=$! # Wait for both wait $PID1 $PID2 echo "Both agents finished" cat /tmp/types-agent.txt cat /tmp/docs-agent.txt ``` ### Example 3: Agent with structured output **User request:** "Analyze the codebase and list all TODO comments with suggested fixes" **Actions:** ```bash claude -p "Search the entire src/ directory for TODO, FIXME, and HACK comments. \ For each one, output a JSON array with objects containing: file, line, comment, \ and suggestedFix. Only output the JSON, no other text." \ --output-format text > /tmp/todos.json 2>&1 # Parse and display cat /tmp/todos.json | python3 -m json.tool ``` ## Guidelines - Always scope tasks narrowly. Agents work best with focused, well-defined objectives. - Use `--output-format text` or `--output-format json` for programmatic consumption. - Set reasonable timeouts for background processes to avoid runaway agents. - Never spawn agents for tasks involving secrets, credentials, or destructive operations. - Review all agent output before presenting it to the user or applying changes. - For parallel agents, ensure they work on non-overlapping files to avoid conflicts. - Capture both stdout and stderr to diagnose failures. - Prefer spawning one agent per well-defined task over one agent for many tasks. - If an agent fails, read its output, diagnose the issue, and either retry with a refined prompt or handle the task directly.
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.