Repository navigation
📝 Update delegation skill to pack into .moca-delegate/ inside the project - #605
Conversation
Signed-off-by: Evaline Ju <[email protected]>
Signed-off-by: Evaline Ju <[email protected]>
moonlight16
left a comment
There was a problem hiding this comment.
Thanks, the direction is right. Packing in-tree avoids the CLIs' working-directory boundary, and the literal rm -r .moca-delegate allow is much tighter than a wildcard rm -r. One gap, though: a previous pack can end up inside the next one.
I ran contextctl ctx pack (v0.3.0) with the output inside the directory being packed:
| Case | Result |
|---|---|
Git repo, no .gitignore entry, empty .moca-delegate/ |
fine: the output isn't packed into itself |
| Same repo, second run, previous pack not cleaned up | the old repo.context is packed into the new one |
With .moca-delegate/ in .gitignore |
fine in every case |
| Not a git repo | .moca-delegate/ is always packed, whatever .gitignore says, since ignore rules only apply inside a git work tree |
| Re-run with the same output name | fails with "bundle already exists" |
Must-fix: the skill relies on the agent editing .gitignore, and that only works in a git repo. Step 1 says to make sure .moca-delegate/ is in a .gitignore, but gives no command for it, and neither allow list lets the agent edit .gitignore. Outside a git repo no .gitignore is read at all, so a pack left by an interrupted run is uploaded inside the next one.
- The fix I'd prefer:
ctx packskips.moca-delegateitself, the way it skips.gitand.claude, or better, skips any file at its own-opath. That's a small Context Service change, and then the skill needs no.gitignorestep. I'm happy to make it. - In the meantime, the skill could start step 1 with
rm -rf .moca-delegate && mkdir .moca-delegate, so nothing can be left over to pack.
Suggestions:
- Step 1's explanation of the self-packing case ("would otherwise pack
.moca-delegate/repo.contextinto the next.moca-delegate/repo.context") could be one sentence. rm -r .moca-delegateis relative, so it's only scoped if the agent runs it from the project root. The skill assumes that throughout, but a line saying so would help.- Not for this PR: #604 (two-user demo) adds
mocactl workloads create --sandboxes N --mount read-only|writable. Whichever of the two lands second should mention them in the skill.
Signed-off-by: Evaline Ju <[email protected]>
moonlight16
left a comment
There was a problem hiding this comment.
Thanks, this addresses everything: step 1 now clears and recreates .moca-delegate/, so a leftover pack can't be uploaded inside the next one, git repo or not; the project-root note is in; and the step 1 text is tighter. No Context Service change needed with this approach.
One non-blocking suggestion: the allow rule is now the compound Bash(rm -rf .moca-delegate && mkdir .moca-delegate). Today Claude Code matches a compound command as one string, so it works only if the agent types it exactly, and there are open requests (anthropics/claude-code#16561, #29491) to evaluate each part of && separately, which would stop this rule from matching. Splitting it into two commands, rm -rf .moca-delegate then mkdir .moca-delegate, each with its own allow rule, works either way.
Signed-off-by: Evaline Ju <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Approving: packing into .moca-delegate/ inside the project avoids the coding-agent CLIs' working-directory boundary. Splitting the clear/recreate into two commands with two literal allow rules matches the skill's own "run each command on its own" rule and works whether or not the CLI checks permissions per subcommand.
One non-blocking item is inline: nothing actually gitignores the in-tree pack directory, contrary to the PR description. Also minor: references/internal-flow.md:10-11 still shows -o repo.context and could be updated to the .moca-delegate/ path.
| 1. Make a temporary directory outside the working tree and keep the path it prints. The packed file | ||
| is a full copy of the directory, so it must not land in the repository, where it could be | ||
| committed or packed again. | ||
| 1. Pack into `.moca-delegate/` in the project root — **not** `/tmp/`, `/var/folders/`, or any |
There was a problem hiding this comment.
suggestion: The PR body says .moca-delegate/ is "gitignored to keep it out of its own future packs", but nothing in the diff gitignores it, and the skill doesn't tell the agent to. The old flow kept the pack outside the tree. Now a run interrupted before cleanup leaves a full copy of the packed project (repo.context) in the working tree, where a later git add -A / git commit -a would pick it up. Consider one line telling the agent to add .moca-delegate/ to .git/info/exclude in a git repo. That file is local, so it doesn't touch the tracked .gitignore. Or at least correct the PR description.
Summary
The
moca-delegate-taskskill told the agent tomktemp -doutside the working tree and pack there, with cleanuprm -r <that path>. This PR packs into.moca-delegate/inside the working tree (gitignored to keep it out of its own future packs) and cleans up withrm -r .moca-delegate.Modern coding-agent CLIs that follow this skill (Claude Code 2.x, OpenCode 1.19.x) enforce a working-directory boundary separate from their shell allow lists — the old flow's cleanup was denied even when the allow list permitted it, forcing a prompt or leaking the temp dir on every run; packing in-tree removes that boundary entirely and lets the cleanup permission tighten from a wildcard-adjacent rm -r TMP_DIR to a scoped literal rm -r .moca-delegate.
Validated against
Assisted-By: Claude (Anthropic AI) [email protected]
Checklist
git commit -s).make lintand the tests for the touched packages pass.docs/page, with the right maturity label (seedocs/CONTRIBUTING-DOCS.md). - N/Amake check-linkspasses if any Markdown changed. - N/Adocs/specs/README.mdordocs/adrs/README.md. - N/A