cancel-swarm
Cancel the active swarm loop
What this skill does
# Cancel Swarm Loop
Check for active swarm loop instances and cancel the selected one:
1. Use Glob to find all active instances:
```
Glob: .claude/swarm-loop/*/state.json
```
2. If no files are found, report that no swarm loop is running and stop.
3. Read each state file to extract: `session_id`, `goal`, `iteration`, `mode`, `team_name`.
4. If exactly one instance exists, proceed to cancel it. If multiple instances exist, show a summary table:
| Instance ID | Goal | Iteration | Mode |
|---|---|---|---|
| `<id>` | `<goal>` | `<n>` | `<mode>` |
Then use `AskUserQuestion` to ask the user which instance to cancel (by ID or number).
5. Once the target instance is selected, note its directory path: `.claude/swarm-loop/<id>/`
6. Read `.claude/swarm-loop/<id>/state.json` to get the current iteration, team_name, goal, and mode. Then call `TaskList` to get current task status.
7. If the state file has a non-null `team_name` field:
- Send a shutdown_request to all teammates via SendMessage (broadcast to `"*"`)
- Call TeamDelete to clean up the team and all associated task records
- Note: **This is the ONLY place TeamDelete is called.** Normal loop completion shuts down teammates but does NOT call TeamDelete.
- If TeamDelete fails (team already gone), continue anyway.
8. Remove swarm loop files for the selected instance (preserve log.md for reference):
```bash
rm .claude/swarm-loop/<id>/state.json
rm -f .claude/swarm-loop/<id>/verify.sh
rm -f .claude/swarm-loop/<id>/next-iteration
rm -f .claude/swarm-loop/<id>/heartbeat.json
rm -f .claude/swarm-loop/<id>/deepplan.*
rm -f .claude/swarm-loop/<id>/progress.jsonl
rm -f .claude/swarm-loop/<id>/.idle-retry.*
```
9. Check if any other instances remain:
```bash
ls .claude/swarm-loop/*/state.json 2>/dev/null
```
10. Restore settings from backup ONLY if no other instances remain:
- If `.claude/settings.local.json.swarm-backup` exists, restore it:
move `.claude/settings.local.json.swarm-backup` to `.claude/settings.local.json`
- If no backup exists, fall back to selectively removing only swarm-generated content from `settings.local.json`:
- Remove entries containing "swarm-loop" from `permissions.allow`
- Remove only hook matcher objects tagged with `"_swarm": true` from each event key — preserve any user-defined hooks
- If a hook event array becomes empty after filtering, remove the event key; if `.hooks` is empty, remove it entirely
- Use jq: `jq '.permissions.allow = ([.permissions.allow[]? | select(test("swarm-loop|deepplan") | not)] | unique) | if .hooks then .hooks |= with_entries(.value = [.value[]? | select(._swarm != true)] | select(.value | length > 0)) | if (.hooks | length) == 0 then del(.hooks) else . end else . end' .claude/settings.local.json`
- If other instances remain, skip the settings restore — the running loops still need the hooks.
11. Report to the user:
- The goal that was being worked on
- The mode (profile) in use at the time of cancellation
- Current iteration number at the time of cancellation
- Task status summary from `TaskList` (how many completed, in-progress, pending)
- Confirm all files were cleaned up
- Note that `.claude/swarm-loop/<id>/log.md` is preserved for reference
Do NOT delete the instance log file — it contains valuable history the user may want to review.
Note: If teammates were using worktree isolation, Claude Code normally cleans up worktrees when agents finish. If cancellation kills teammates mid-work, orphaned worktrees may remain at `.claude/worktrees/`. These can be cleaned up manually with `git worktree list` and `git worktree remove`.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.