Skip to content

Coder code patterns, refactor-first guidance, and structural task blocking - #9

Merged
wparad merged 3 commits into
mainfrom
claude/code-patterns-early-returns-fznmgy
Jun 30, 2026
Merged

Coder code patterns, refactor-first guidance, and structural task blocking#9
wparad merged 3 commits into
mainfrom
claude/code-patterns-early-returns-fznmgy

Conversation

@wparad

@wparad wparad commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extends AgentRole::Coder's default system prompt (src/dispatcher/mod.rs) with explicit code-pattern guidance, following the same approach used for the Designer role's prompt extension:
    • Prefer early returns with if over if/else.
    • Avoid else if chains — use early returns or a match/switch instead.
    • Prefer default/fallback expressions for map lookups (e.g. dict[key] || default, map.get(key).unwrap_or(default)) over if/else value assignment.
  • Adds refactor-first behavior to the Coder prompt: before implementing, the Coder checks whether refactoring existing code first would make the task trivial. If so, it creates a separate refactor ticket (gitzi_create_task) under the same epic, asks the human to confirm via gitzi_create_review_item, and — once accepted in a later run — blocks the original task on the refactor ticket instead of refactoring inline.
  • Adds structural task blocking to support that flow:
    • Task gains a blocked_by: Vec<String> field (src/model/task.rs).
    • KanbanBoard::next_unblocked (src/dispatcher/board.rs) picks the highest-priority task in a column whose blockers have all reached Stage::Done; an unknown blocker ID fails closed (task stays blocked).
    • agent_pool.rs's task pick-up loop now calls next_unblocked instead of taking the column's first task unconditionally.
    • New gitzi_block_task(task_id, blocked_by) tool, wired through protocol.rs (schema), tools.rs (dispatch + ownership check), and coding_tools.rs (CodingLoop fallback). It moves the task back to the top of Prioritized and records the blocker list — unlike gitzi_park_task, which is a free-text note only, this is a structural link the pipeline enforces.

Test plan

  • cargo build — succeeds
  • cargo test --lib — all 90 tests pass, including new KanbanBoard::next_unblocked cases (no blockers, unfinished blocker, blocker reaches Done, unknown blocker ID)
  • cargo clippy --lib — no warnings

Generated by Claude Code

claude added 2 commits June 30, 2026 10:34
Extends the Coder role's default system prompt with explicit code
style guidance: prefer early returns over if/else, avoid else-if
chains, and prefer map lookup defaults/fallbacks over if/else value
assignment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QASDYY4oStKvQBBK9m8GAG
The Coder agent now proposes a separate refactor ticket instead of
refactoring inline when one would make a task trivial to implement, and
waits on human approval before blocking the original task on it via a
new gitzi_block_task tool. Tasks gain a blocked_by list, and the agent
pool's task pick-up skips tasks whose blockers haven't reached Done
(KanbanBoard::next_unblocked), enforcing the link structurally rather
than as a free-text note.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QASDYY4oStKvQBBK9m8GAG
@wparad wparad changed the title Add early-return and map-default code pattern rules to Coder prompt Coder code patterns, refactor-first guidance, and structural task blocking Jun 30, 2026
tools_list_returns_all_seven_tools hardcoded an expected count of 7
gitzi_* tools, which went stale once gitzi_block_task was registered.
Bump to 8, add the new tool to the expected name list, and rename the
test so it no longer encodes a count in its name.
@wparad
wparad merged commit 567cdce into main Jun 30, 2026
1 check passed
@wparad
wparad deleted the claude/code-patterns-early-returns-fznmgy branch June 30, 2026 16:02
wparad added a commit that referenced this pull request Jul 25, 2026
…fznmgy

Coder code patterns, refactor-first guidance, and structural task blocking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants