| name | ticket-completing |
| description | Complete a task ticket in KanbAgent following the mandatory order. Activates when an agent finishes work on a task, when user says "mark as done", "ticket done", "close ticket", "close task". Enforces comment-first then done order, session closure, and backlog check. |
Ticket Completing Skill
Handles the mandatory completion sequence for KanbAgent tickets. Order is critical — deviating from it causes data integrity issues (cf. T430, T437, T438).
When to Use
- Agent finishes implementing a task
- User says "done", "terminé", "close the ticket", "marquer done"
- Work on a ticket is complete and ready for review
Mandatory Order: Comment FIRST, then done
If the session expires between the two calls, the comment is already persisted.
Reversing the order risks done with no comment.
Completion Sequence
Step 1 — Write the Completion Comment FIRST
Use a single heredoc to atomically write comment + status in one call:
node scripts/dbw.js <<SQL
INSERT INTO task_comments (task_id, agent_id, content)
VALUES (:task_id, :agent_id, '<comment — see format below>');
UPDATE tasks SET status = 'done', completed_at = CURRENT_TIMESTAMP,
updated_at = CURRENT_TIMESTAMP WHERE id = :task_id;
SQL
Comment Format
files:lines · done · choices · remaining · to validate
Be specific and self-contained. Example:
src/main/ipc-agents.ts:45-67 · Added getAgentGroups handler · Used LEFT JOIN for nullable parent_id · No migration needed · Validate: call from renderer returns nested groups correctly
Step 2 — Check the Backlog
SELECT id, title, priority FROM tasks
WHERE agent_assigned_id = :agent_id AND status = 'todo'
ORDER BY priority DESC, created_at ASC LIMIT 5;
If remaining tasks exist:
→ Chain immediately without closing the session
→ /clear + PTY reset, then take the next ticket (see agent-session-starting skill for steps 3-4)
→ Do NOT close the session yet
If no remaining tasks:
→ Proceed to Step 4
Step 3 — Close the Session (only if no tasks remain or blocked)
node scripts/dbw.js <<SQL
UPDATE sessions SET
tokens_in = ,
tokens_out = ,
tokens_cache_read = ,
tokens_cache_write = ,
status = 'completed',
ended_at = CURRENT_TIMESTAMP,
updated_at = CURRENT_TIMESTAMP,
summary = 'Done:. Pending:. Next:.'
WHERE id = :session_id;
SQL
Token values: displayed by Claude Code at end of conversation as:
Tokens: X in, Y cache_read, Z cache_write, W out
If unknown (interrupted session) → set to 0.
Summary format: max 200 chars, self-contained. Example:
Done:T912 IPC handler for agent groups. Pending:none. Next:review to validate nested group queries.
Edge Cases
Ticket rejected by review
-- review sets status back to 'todo' with a comment
-- agent re-reads the rejection comment, fixes, and re-completes using this skill
SELECT tc.content FROM task_comments tc WHERE tc.task_id = :task_id ORDER BY tc.created_at DESC LIMIT 3;
Session blocked (dependency)
UPDATE sessions SET status = 'blocked', updated_at = CURRENT_TIMESTAMP,
summary = 'Blocked:. Waiting:.' WHERE id = :session_id;
Then stop. Do not mark the task as done.