Phase 3: Agent Label Behavior — PostToolUse hooks + forgejo-helper extensions #51
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/claude-custom#51
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?
Plan
plan-2026-03-03-sprint-workflow-automation-- Phase 3 (traceability only)Repo
forgejo_admin/claude-customUser Story
As a platform operator
I want agent workflow transitions to automatically set Forgejo labels on issues
So that sprint boards reflect real status without manual intervention
Context
Agents interact with Forgejo via MCP tools (create_issue_and_branch, submit_pr, comment_on_pr). Currently, no labels are set when these tools fire. Phase 1 created 7 standard labels across 29 repos. Phase 2 documented the protocol in SOPs. This phase implements the enforcement layer — PostToolUse hooks that automatically set status labels when agents use MCP tools.
Three enforcement layers (hooks > skills > prompts):
The forgejo-mcp server currently has NO
set_labelorcomment_on_issuetools. Hooks bypass this gap by using curl via forgejo-helper.sh.Important implementation detail: Forgejo's label API has no "replace by prefix" —
forgejo_set_label()must GET current labels, filter out existingstatus:*labels, add the new one, and PUT the full list back. This requires 2 API calls (GET + PUT), not one.File Targets
Files to modify:
hooks/forgejo-helper.sh— addforgejo_set_label(),forgejo_comment_on_issue(),forgejo_get_issue_number_from_branch()functionssettings.json— register 3 new PostToolUse hooks (for create_issue_and_branch, submit_pr, comment_on_pr)agents/dev.md— add awareness section about automatic label hooksagents/qa.md— add awareness section about automatic label hooks and VERDICT parsingFiles to create:
hooks/label-on-branch.sh— PostToolUse hook formcp__forgejo__create_issue_and_branch: setsstatus:in-progresslabelhooks/label-on-pr.sh— PostToolUse hook formcp__forgejo__submit_pr: setsstatus:qalabel + comments PR URL on issuehooks/label-on-verdict.sh— PostToolUse hook formcp__forgejo__comment_on_pr: parses VERDICT from comment body, setsstatus:approvedorstatus:needs-fixFiles NOT to touch:
hooks/remind-mcp-review-loop.sh— existing hook, keep as-is. New label-on-pr.sh is a separate PostToolUse hook in the array, not a replacement.agents/betty-sue.md— Betty Sue's profile is not part of this phase.Acceptance Criteria
create_issue_and_branch, hook automatically setsstatus:in-progresslabel on the new issuesubmit_pr, hook automatically setsstatus:qalabel on the parent issue AND comments the PR URL on the issuecomment_on_prwith body containing### VERDICT: APPROVED, hook setsstatus:approvedlabel on parent issuecomment_on_prwith body containing### VERDICT: NOT APPROVED, hook setsstatus:needs-fixlabel on parent issuecomment_on_prbody has NO verdict pattern, hook is a no-op (not all PR comments are reviews)status:qaremovesstatus:in-progress, etc. Only onestatus:*label at a time.hookSpecificOutput.additionalContextfor inject messages)Test Expectations
forgejo_set_label()correctly replaces status labels (GET + filter + PUT pattern)forgejo_get_issue_number_from_branch()handles branch pattern{issue-num}-{description}label-on-verdict.shonly fires on VERDICT lines, not arbitrary PR commentsConstraints
source "$HOME/.claude/hooks/forgejo-helper.sh"pattern for credential loading--connect-timeout 5 --max-time 10and-s(silent) per existing patternssubmit_prhook needs to extract the issue number. Convention: branch names are{issue-num}-{description}. Extract from the PR's head branch field in the tool output.create_issue_and_branchandcomment_on_prneed new matcher entries.Checklist
Related
project-claude-config-- project this affectsplan-2026-03-03-sprint-workflow-automation-- parent plantodo-forgejo-mcp-label-comment-tools-- MCP gap these hooks work around