Synthèse automatique
Lance un sous-agent sous forme de véritable sous-processus `claude` dont le répertoire de travail est limité à un dossier choisi, ou à un worktree git dédié créé pour l'occasion, afin d'imposer une isolation au niveau du système de fichiers.
Points forts
- L'isolation est appliquée par le système de fichiers (cwd du sous-processus), pas par une simple consigne dans le prompt que l'agent pourrait ignorer.
- Peut créer ou réutiliser automatiquement un git worktree dédié, confinant réellement toute la vue du sous-agent.
- Renvoie un résultat comparable à l'outil Agent intégré : résumé texte plus statut de succès/sortie.
- Conçu de façon générique, réutilisable par n'importe quel projet et pas seulement par son projet d'origine.
Limites
- Spécifique à Claude Code : dépend du CLI `claude` et suppose Bun pour exécuter les scripts TypeScript.
- Surcoût réel (démarrage d'un sous-processus, gestion du worktree), injustifié pour des tâches sans écriture de fichiers.
- Un worktree fraîchement créé ne voit pas les modifications non commitées de la session appelante.
À utiliser pour tout travail d'implémentation qui crée, modifie ou supprime des fichiers et où l'on veut limiter physiquement le rayon d'action du sous-agent à un seul répertoire.
À éviter pour de la recherche en lecture seule, des recherches de code ou des analyses purement textuelles, où l'outil Agent intégré reste plus léger.
Analyse de sécurité
PrudenceThe skill is a legitimate process-isolation utility that launches Claude Code as a subprocess scoped to a directory, optionally with a dedicated git worktree. It does not itself contain destructive or exfiltrating instructions, but it delegates execution to a powerful agent and offers a bypassPermissions mode, which removes normal safety prompts. This warrants caution rather than safe, though it is not inherently risky when used as intended.
- •Optional --permission-mode bypassPermissions can disable interactive permission checks for the spawned Claude Code subprocess, allowing it to perform unrestricted file modifications and command execution within its working directory.
- •The skill spawns an external claude CLI process with an arbitrary prompt, which could be influenced to perform exfiltration or destructive actions if the invoking prompt is malicious or confused.
- •No allowed-tools are declared, yet the scripts invoke bun and claude, both capable of executing arbitrary code and network operations.
Exemples
Dispatch a forked sub-agent in a new git worktree to implement TICKET.md, then report what it changed and the exit status.Run this refactor via the forked-subagent dispatch script with --dir pointed at /path/to/worktree so it cannot touch the shared checkout.Use forked-subagent with --prompt-file tasks/implement.md and --model sonnet against the dedicated worktree, then summarize the result.name: forked-subagent
description: "Dispatch a sub-agent as a real OS subprocess (the claude CLI, non-interactive) with its cwd hard-scoped to a target directory — optionally a dedicated git worktree it creates for you — instead of the in-process Agent tool's shared checkout. Use this whenever a sub-agent will write files and you want filesystem-enforced isolation rather than directory-ownership convention: implementation work, anything with real file-write risk, or any task where a confused sub-agent writing outside its assigned scope would be a real problem. Not a full replacement for the in-process Agent tool — for read-only research, quick lookups, or anything that doesn't write files, Agent remains lower-overhead (no subprocess spin-up, no worktree bookkeeping)."
forked-subagent
Launches Claude Code as a genuine child process (claude -p ...) with cwd set to a
directory you choose, waits for it to finish, and returns a result comparable to what the
in-process Agent tool gives you: a text summary plus success/exit status. Optionally
creates (or reuses) a dedicated git worktree first, so the sub-agent's entire filesystem
view really is confined to that worktree — not just conventionally scoped by a prompt
instruction it could ignore or misread.
Built for Dark Harness ticket tracking/DH-0114-*.md: this project's own coordinator was
dispatching implementers via the in-process Agent tool against one shared checkout, relying
on directory ownership (CLAUDE.md §3) as a convention rather than a hard boundary — a
confused sub-agent had already once written outside its assigned domain, swept another
agent's staged files into a commit, and briefly broke main. This skill is not Dark
Harness-specific, though — it's checked in generically so any project can reuse "launch a
real forked claude subprocess scoped to a directory" (per the ticket's second User Story).
All scripts are TypeScript, run directly with bun (no build step, no separate install) —
unlike .claude/skills/spile-ops/ (Python-stdlib-only, explicitly outside this repo's Bun
toolchain), this skill spawns claude itself and reads its JSON output, so Bun is the
natural fit. Nothing here lives under src/ or is wired into dh's own build/typecheck/test
gates — it's coordinator/process tooling, not part of the dh product.
When to use this vs. the in-process Agent tool
- Use forked-subagent for implementation work — anything that will create, edit, or delete files, or run commands with side effects — where you want the sub-agent's blast radius physically limited to one directory (typically a dedicated worktree), independent of whether its prompt correctly self-scopes.
- Use the in-process
Agenttool for read-only research, code search, quick lookups, or analysis that produces only a text report — no file-write risk, so the overhead of spinning up a real subprocess (and, if using worktrees,git worktree add/cleanup) buys nothing.Agentis also the right choice when you want the sub-agent to see files the invoking session has already touched in the same shared checkout (uncommitted state a fresh worktree wouldn't have). - This skill does not replace
Agent— it's an additional, higher-isolation dispatch path for the subset of tasks where isolation actually matters.
Scripts
All under scripts/, invoked directly with bun:
dispatch.ts — the low-level primitive: run claude in a directory
bun .claude/skills/forked-subagent/scripts/dispatch.ts \
--dir /path/to/some/directory \
--prompt "Implement the thing described in TICKET.md. Report what you changed."
Flags:
--dir <path>(required) — the subprocess'scwd. Any plain directory works; it does not need to be a git worktree.--prompt "text"or--prompt-file <path>(exactly one required).--model <name>— optional, forwarded toclaude --model.--permission-mode <mode>— optional, forwarded toclaude --permission-mode(e.g.acceptEdits,bypassPermissions) if you want the sub-agent to run without interactive prompts. Omit it to inherit whatever the ambientclaudeconfig/classifier does by default.--timeout-ms <n>— optional; kills the subprocess and returns a failure result if it doesn't finish in time.
Runs claude -p <prompt> --output-format json under the hood (verified against this
environment's real claude --help), parses the JSON result envelope, and prints one JSON
object to stdout:
{
"success": true,
"exitCode": 0,
"result": "<claude's final text output>",
"sessionId": "...",
"costUsd": 0.08,
"durationMs": 2511,
"dir": "/path/to/some/directory",
"raw": { "...": "the full --output-format json payload" }
}
The process's own exit code mirrors the subprocess's exit code, so callers that only care
about pass/fail can check $? without parsing JSON.
worktree.ts — create/reuse and clean up a git worktree
bun .claude/skills/forked-subagent/scripts/worktree.ts create \
--repo /path/to/repo --branch DH-0114-thing [--base main] [--path <explicit-dir>]
bun .claude/skills/forked-subagent/scripts/worktree.ts cleanup \
--repo /path/to/repo --path <worktree-dir> --branch DH-0114-thing [--force] [--keep-branch]
createprints the worktree's absolute path on stdout. If a worktree already exists at the default (or given) path and is a registered worktree of the repo, it's reused rather than re-created. If the branch already exists, the worktree is attached to it instead of trying to-ba duplicate.- Default worktree location: a sibling directory
<repo>-worktrees/<branch>next to the repo (never nested inside it). cleanupfollows the same discipline as theWorkflowtool'sisolation: "worktree"mode: remove the worktree (and its branch, unless--keep-branch) only if it has no uncommitted changes and its branch is fully merged into the base ref (--base, defaultHEAD) it was created from. Otherwise it's left in place and the reason is printed, so a failed or still-in-progress run can be inspected rather than silently lost.--forceskips both checks and removes unconditionally (e.g. a known-bad run you don't need to inspect).
run-in-worktree.ts — the combined flow (User Story 1, end to end)
bun .claude/skills/forked-subagent/scripts/run-in-worktree.ts \
--repo /path/to/repo \
--branch DH-0114-thing \
--prompt "Implement the thing described in TICKET.md." \
[--base main] [--model sonnet] [--permission-mode acceptEdits] [--keep]
Creates/reuses the worktree, dispatches claude into it, then applies the cleanup discipline
above (pass --keep to skip cleanup entirely and always leave the worktree, e.g. while
iterating). Prints one JSON object combining dispatch.ts's result with worktreePath,
branch, and a cleanup field (null if --keep was passed). Exit code mirrors the
sub-agent's own exit code.
Tests
Real integration tests — no mocking of child_process/git, since a script whose entire job
is spawning a subprocess or a git worktree can't be meaningfully unit-tested by mocking that
call (see CLAUDE.md §9). Run on demand (not part of dh's own bun run test:coverage
gate):
bun test ./.claude/skills/forked-subagent/scripts/worktree.test.ts # real git, no API cost
bun test ./.claude/skills/forked-subagent/scripts/dispatch.test.ts # real claude subprocess, small API cost
bun test ./.claude/skills/forked-subagent/scripts/run-in-worktree.test.ts # both combined, small API cost
worktree.test.tsexercisescreateWorktree/cleanupWorktreeagainst real scratch git repos: fresh creation, reuse, dirty-worktree-left-in-place, unmerged-but-clean-left-in-place, merged-and-clean-removed, and--force.dispatch.test.tsspawns a realclaude -psubprocess against a scratch directory and checks the parsed result shape and a real file-write round-trip.run-in-worktree.test.tsis the full end-to-end proof for the isolation guarantee this skill exists for: a realclaudesubprocess writes and commits a file inside a real, dedicated worktree, and the test asserts that file exists in the worktree but not in the shared repo checkout — then exercises the merge-then-cleanup path.
Design notes
claude --output-format json's result envelope (is_error,result,session_id,total_cost_usd,duration_ms, ...) was confirmed against this environment's real installedclaude --helpand a liveclaude -p ... --output-format jsonrun — not assumed from memory.dispatch.tshas no git awareness at all; it only knows "run claude in this directory."worktree.tshas no claude awareness; it only knows git worktree lifecycle.run-in-worktree.tscomposes the two. Keeping them separate means either can be used standalone — e.g.dispatch.tsagainst a plain scratch directory with no git involved at all, orworktree.tsto prep a worktree for a completely different tool.git branch --mergedprefixes the currently-checked-out branch with*and any branch checked out in another worktree with+—cleanupWorktree's merged-branch check strips both prefixes before matching (an easy bug to miss; caught it via the real-git integration test failing on the merged-cleanup case during development, not by inspection).
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/forked-subagent-mrzxuoue/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
mkdir -p '.skill-downloads/forked-subagent-mrzxuoue' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/forked-subagent-mrzxuoue/download' --output '.skill-downloads/forked-subagent-mrzxuoue/SKILL.md.part' && mv '.skill-downloads/forked-subagent-mrzxuoue/SKILL.md.part' '.skill-downloads/forked-subagent-mrzxuoue/SKILL.md'2. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.
Claude Code
test -f '.skill-downloads/forked-subagent-mrzxuoue/SKILL.md' && test -s '.skill-downloads/forked-subagent-mrzxuoue/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/forked-subagent' && cp -R '.skill-downloads/forked-subagent-mrzxuoue' '.claude/skills/forked-subagent'OpenSkills
OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.
Installation officielle d’OpenSkillsopenskills install './.skill-downloads/forked-subagent-mrzxuoue'openskills read 'forked-subagent-mrzxuoue'La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.
Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.
openskills syncMode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/forked-subagent-mrzxuoue/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Bonnes pratiques React Hook Form
Developpement
Maîtrisez React Hook Form : évitez les anti-patterns, gérez les abonnements, et traitez correctement reset, dirty state et entrées contrôlées.
Migration Emotion vers Mantine
Developpement
Migrer les styled-components Emotion vers des composants Mantine avec style props et modules CSS. Pour convertir .styled.tsx ou supprimer les imports @emotion.
Détecteur de dérive de périmètre
Developpement
Analyse les diffs git par rapport à une intention pour détecter la dérive de périmètre, fichiers non liés et PR trop larges, puis suggère de garder, diviser ou justifier.