Skills: forbid mcp__forgejo__update_file for code edits (use Edit/Write + git CLI) #79
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks#79
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
User story
As the operator, I want the code-flow skills (
implement,address-review,rebase,fix-ci) to explicitly steer agentstoward Edit / Write + git CLI for code changes, and reserve
mcp__forgejo__*for issue / PR / comment operations only — sothat Sonnet agents stop hitting the prompt-token limit on multi-turn
tasks that involve large files.
What happened (concrete)
#77 was assigned to
devas the first container-mode validation fora code agent. Dev ran for 51 turns, landed 3 of 4 commits correctly
(
1cd3633,3859f04,b34dd47on branchdev/77), then died onturn 52 with
Prompt is too longwhen it tried to call:The
contentargument was the full file body. Combined with theprior 51 turns of conversation, the aggregate token count blew past
Sonnet's prompt window. The agent already had the file cloned in its
worktree (
/state/worktrees/dev/charles__claude-hooks__dev%2F77/).It could have used
Editfor a targeted diff, orWritetooverwrite locally and then
Bashforgit add / commit / push.The work product is otherwise correct — container-mode infrastructure
worked, the implementation logic was right. This is a skill-guidance
bug, not an infra bug.
Why this class of failure matters
Every Sonnet code agent (
devtoday;reviewerfor its own PRseventually) runs on a ~200k prompt budget. A large file × several
turns of context = overflow. The failure mode is silent until it
happens, and when it does the agent is mid-task. The cheapest
prevention is a skill-level rule: do not use Forgejo's RPC
update_file/create_filefor code changes. They exist forout-of-band fixes (web UI edits, hotfixes with no local clone) and
are wrong tools when the worktree is right there.
Acceptance criteria
Skills — add an explicit tool-choice rule
skills/implement.md— add a section near the top (right afterthe workflow) that names the tools for each operation:
- Code changes →
Edit(diff) orWrite(full overwrite,small files only) in the local worktree +
Bashforgit add,git commit,git push.- Issue / PR / comment operations →
mcp__forgejo__*(open PR, assign labels, update issue body, post comment).
- Never use
mcp__forgejo__update_file/mcp__forgejo__create_file/mcp__forgejo__delete_fileformodifications to the repo the agent is cloned into —
they're for working on repos without a local checkout and
blow the prompt on files > ~200 lines.
skills/address-review.md,skills/rebase.md,skills/fix-ci.md, and the-delta.mdvariants where present. One canonical paragraph copy-pasted so
every skill's front matter agrees.
Dashboard-visible failure mode
src/agent-runner.ts/main.tslog the specificPrompt is too longerror with a hint pointing at thisticket's rule when it fires. The current task record stores
the last SDK error, so the hint surfaces on the task detail
view in the monitor UI.
Tests
The regression catch is operational (agent's next task
completes without overflow). We'll know it landed when a
large-file cleanup on
devorreviewerfinishes in < 20turns instead of 52.
Out of scope
mcp__forgejo__update_filefor the worktree's own repo incanUseTool, but that's heavier than necessary and would triplegitimate out-of-band edits in the future. Skill-level guidance
first; enforcement only if guidance isn't enough.
existing skills as a paragraph, not a restructure.
update_fileMCP tool itself. No change to forgejo-mcp.The tool is correct; the usage pattern was wrong.
References
d9f5d568-bb75-4467-8438-4ca16ef13d2b,turn 52,
Prompt is too long→API error: invalid_request.skills/{implement,address-review,rebase,fix-ci}.mdplus the
-delta.mdvariants.Dependencies
main.