copilot-sub-agent
Skill3 starsChanged 3 months agoMITView on GitHub
Launch GitHub Copilot CLI as a headless sub-agent in a tmux pane, monitor its JSONL output stream, and poll for completion. Use when delegating a well-defined coding task (bug fix, feature, refactor) to a Copilot agent subprocess with live observability. Triggers include "run copilot agent", "delegate to copilot", "copilot sub-agent", or any request to run copilot headlessly and monitor it.
In this repository86 other files it gives its agents.
- AGENTS.mdAGENTS.md
- adrSkill
- adzic-bddSkill
- agent-md-refactorSkill
- agent-muxSkill
- agent-role-impersonatorSkill
- agilquest-reservationsSkill
- ai-text-humanizerSkill
- architecture-decision-recordsSkill
- ast-grepSkill
- atacSkill
- aws-cliSkill
- bart-adversarial-reviewerSkill
- bddSkill
- branch-doctorSkill
- c4-architectureSkill
- c4Skill
- claude-sub-agentSkill
- codemap-config-setupSkill
- codemap-exploreSkill
- codemap-handoffSkill
- codemap-hub-safetySkill
- codemapSkill
- commitSkill
- daily-standupSkill
- daily-statusSkill
- debugSkill
- design-thinkingSkill
- doctorSkill
- docx-word-processorSkill
- farley-tddSkill
- forensicsSkill
- gemini-sub-agentSkill
- git-commit-formatterSkill
- git-forensicsSkill
- github-actions-permissionsSkill
- github-cliSkill
- git-repo-discoverySkill
- git-safety-guardrailsSkill
- harness-idpSkill
- humanizeSkill
- iteration-plannerSkill
- jira-issue-managerSkill
- justfile-assistantSkill
- kiro-sub-agentSkill
- lessons-learnedSkill
- lessonsSkill
- lisa-planning-agentSkill
- lovejoy-release-agentSkill
- lsp-code-analysisSkill
- macro-to-microSkill
- marge-product-agentSkill
- meeting-notesSkill
- mermaid-diagram-generatorSkill
- modern-cli-overridesSkill
- native-web-searchSkill
- obsidian-notetakerSkill
- outlook-headlessSkill
- pdf-document-processorSkill
- pi-sub-agentSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 85
If you see this, you need COPILOT_API_URL.
- Very specific: line 206
Still slow after setting
COPILOT_API_URL: Check the log for other errors: - Very specific: line 213
Agent not found /
No such agent: bart: Check the filename stem matches what you pass to --agent. - Very specific: line 217
Prompt gets mangled by shell quoting: Always use -p @/tmp/file.md — never inline the prompt string.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot Sub-Agent Skill
Launch copilot as a headless sub-agent in a tmux pane with live JSONL monitoring. Depends on the tmux skill for pane interaction.
When to use
- Delegating a scoped task to GitHub Copilot CLI running autonomously
- Parallel execution alongside other sub-agents (gemini-sub-agent, claude-sub-agent, pi-sub-agent)
- Any situation where you want to observe a Copilot agent working without blocking your session
Output format
Copilot streams JSONL (same schema as pi). Key event types:
session— startup, containsid,timestampagent_start/agent_end— lifecycle boundaries;agent_end= donetool_execution_start/tool_execution_end— tool calls withtoolName,args,resultmessage_end— assistant turn complete, contains final text
Completion signal: "type":"agent_end" line in the JSONL stream.
Non-interactive invocation
Lean / headless invocation
COPILOT_API_URL="https://api.business.githubcopilot.com" \
copilot \
--yolo \
--no-auto-update \
--disable-builtin-mcps \
--no-custom-instructions \
--no-ask-user \
-p @/tmp/task-prompt.md \
> /tmp/copilot-output.jsonl 2>&1What each flag does:
| Flag | Why |
COPILOT_API_URL | Critical for Business/Enterprise — see startup hang section below |
--yolo | Auto-approve all tool calls — required for headless |
--no-auto-update | Skip update check on startup |
--disable-builtin-mcps | Don't load github-mcp-server — removes GitHub MCP tools from context |
--no-custom-instructions | Skip scanning AGENTS.md / .github/copilot-instructions.md |
--no-ask-user | Remove the ask_user tool — prevents agent stalling waiting for input |
-p @file | Non-interactive, read prompt from file and exit |
⚠️ The ~2-minute startup hang: root cause and fix
The CLI first tries api.githubcopilot.com (personal account endpoint). On Copilot Business or Enterprise accounts this endpoint drops TCP connections, causing a 10-second connect timeout retried with exponential backoff across 4 attempts before falling through to the correct endpoint:
Attempt 1: 10s timeout + 5s delay = 15s
Attempt 2: 10s timeout + 10s delay = 20s
Attempt 3: 10s timeout + 20s delay = 30s
Attempt 4: 10s timeout + 40s delay = 50s
Total: ~115sFix — force the correct endpoint via COPILOT_API_URL:
# Copilot Business or Enterprise:
export COPILOT_API_URL="https://api.business.githubcopilot.com"
# GHE.com data-residency accounts:
export COPILOT_API_URL="https://copilot-api.{tenant}.ghe.com"
# Personal/individual accounts (default, no env var needed)With this set, startup drops from ~2 minutes to ~7 seconds. Add to your shell profile.
Diagnose: check ~/.config/.copilot/logs/process-*.log:
ConnectTimeoutError: Connect Timeout Error (attempted address: api.githubcopilot.com:443)
Retrying request to GitHub API in 5 seconds. Attempt 1/5If you see this, you need COPILOT_API_URL.
Agent frontmatter format
Agent .md files in ~/.config/copilot/agents/ must use copilot's format — plain pi-style files will log custom agent markdown frontmatter is malformed and be silently ignored. See the Agent/persona section for the correct .agent.md format.
Other useful flags:
--model <model>— override model (default: claude-sonnet-4.5)--share /tmp/session.md— export full session as markdown--autopilot— enable multi-step continuation--max-autopilot-continues <n>— cap autopilot iterations
For full flag reference, read references/copilot-cli-reference.md.
Workflow
1. Write the task prompt to a file
cat > /tmp/task-prompt.md << 'EOF'
Your task description here.
EOF2. Identify a free tmux pane
bash {SKILLS_DIR}/tmux-remote-control/scripts/tmux-list.sh3. Launch copilot + monitor in the pane
TARGET="{session}:{window}.{pane}"
tmux send-keys -t "$TARGET" \
"cd /path/to/repo && copilot --yolo -p @/tmp/task-prompt.md > /tmp/copilot-output.jsonl 2>&1 &" Enter
sleep 3
tmux send-keys -t "$TARGET" \
"python3 {SKILLS_DIR}/copilot-sub-agent/scripts/monitor.py /tmp/copilot-output.jsonl" Enter4. Poll for completion
python3 {SKILLS_DIR}/copilot-sub-agent/scripts/poll.py "$TARGET" --interval 305. Verify results
tmux send-keys -t "$TARGET" C-c # kill monitor
git log --oneline -5Full copy-paste pattern
cat > /tmp/task-prompt.md << 'EOF'
Your task here.
EOF
TARGET="{session}:{window}.{pane}"
tmux send-keys -t "$TARGET" \
"cd /path/to/repo && COPILOT_API_URL=https://api.business.githubcopilot.com copilot --yolo --no-auto-update --disable-builtin-mcps --no-custom-instructions --no-ask-user -p @/tmp/task-prompt.md > /tmp/copilot-output.jsonl 2>&1 &" Enter
sleep 3
tmux send-keys -t "$TARGET" \
"python3 {SKILLS_DIR}/copilot-sub-agent/scripts/monitor.py /tmp/copilot-output.jsonl" Enter
python3 {SKILLS_DIR}/copilot-sub-agent/scripts/poll.py "$TARGET" --interval 30
tmux send-keys -t "$TARGET" C-c
git log --oneline -5Agent / persona injection
Copilot --agent looks up a {stem}.agent.md file by its filename stem (not its name: frontmatter field). Search order:
.github/agents/{stem}.agent.md— project-level (in repo root)~/.config/copilot/agents/{stem}.agent.md— user-level
File format (frontmatter + markdown system prompt):
---
name: Bart
description: Adversarial code reviewer
tools: ["read_file", "run_shell_command"]
model: ["claude-sonnet-4.6"]
---
You are Bart Simpson, adversarial reviewer. Find bugs and be snarky.Use it:
# Install agent file to user config (persists across repos)
cp {SKILLS_DIR}/bart-adversarial-reviewer/references/bart.md ~/.config/copilot/agents/bart.agent.md
# Or install to project (checked in, team-shared)
cp {SKILLS_DIR}/bart-adversarial-reviewer/references/bart.md .github/agents/bart.agent.md
# Invoke by stem name
copilot --agent bart --yolo -p @/tmp/task.mdNote: The
--agentflag takes the filename stem, not thename:frontmatter value. A file namedbart.agent.md→--agent bart.
Model selection
copilot --model claude-haiku-4.5 --yolo -p @/tmp/task.md # fast/cheap
copilot --model claude-sonnet-4.6 --yolo -p @/tmp/task.md # default
copilot --model claude-opus-4.6 --yolo -p @/tmp/task.md # most capableTroubleshooting
Still slow after setting COPILOT_API_URL: Check the log for other errors:
tail -20 ~/.config/.copilot/logs/$(ls -t ~/.config/.copilot/logs/ | head -1)unknown option '--no-bash-env': This flag is only valid in interactive mode, not with -p. Don't use it.
Agent not found / No such agent: bart: Check the filename stem matches what you pass to --agent. A file bart.agent.md → --agent bart. The name: frontmatter field is ignored for lookup.
custom agent markdown frontmatter is malformed: Pi-format agent files (no tools: array, wrong field names) are rejected. Use the .agent.md format with name, description, tools fields.
Prompt gets mangled by shell quoting: Always use -p @/tmp/file.md — never inline the prompt string.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

