# Consume Tickets

> One-shot ticket consumer — refreshes a ranked roadmap of agent-ready tracker issues, implements the best one via a fresh executor subagent, gates it (review, project gates, runtime check), commits+pushes, reports, exits. Project specifics live in `.claude/ocakbasi.md`. Arg `dry-run` = selection only, no mutations.

- **Type:** Skill
- **Install:** `agentstack add skill-osman-turan-skills-consume-tickets`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [osman-turan](https://agentstack.voostack.com/s/osman-turan)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [osman-turan](https://github.com/osman-turan)
- **Source:** https://github.com/osman-turan/skills/tree/main/ocakbasi/skills/consume-tickets

## Install

```sh
agentstack add skill-osman-turan-skills-consume-tickets
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Consume tickets

One invocation = at most ONE ticket taken end-to-end (select → implement → review → gates → runtime check → commit+push → report), then exit. NO scheduling, pacing, wakeups, or keep-awake — cadence belongs to /loop or the user. Nobody is watching mid-run: never wait on questions; a ticket that needs decisions is skipped for a /ocakbasi:grill-ticket session instead.

Two roles share this file: invoked as `/ocakbasi:consume-tickets` you are MAIN; spawned and pointed at §Executor you are the EXECUTOR. Main stays thin — all heavy work runs inside the executor's fresh, discarded context, because under /loop every token appended to the main conversation is re-read at full price on every later firing.

**Project config** = `.claude/ocakbasi.md`, read first. It carries every project fact: tracker labels, ranking hints, exclusions, preflight commands, gates, the optional runtime check & artifacts protocol, commit authorization. This file carries behavior only. Config missing → copy `templates/ocakbasi.template.md` from the plugin root (this skill lives at `/skills/consume-tickets/`; `$CLAUDE_PLUGIN_ROOT` in a Bash call also resolves it) to `.claude/ocakbasi.md`, tell the user to complete its SETUP comment (TODOs), and stop.

## Guardrails

1. The tracker is READ-ONLY: never comment, close, edit, assign, or change labels. Queue bookkeeping is local (§State dir).
2. Three git tiers. MAIN: `git add/commit/push` only at §Commit, plus `git stash push -u -m "consume-tickets #N "` of this run's own failed work. EXECUTOR: `git add` and `git stash create` only. NESTED WORKERS: no git or tracker mutations at all — every worker prompt carries verbatim: "Git and the issue tracker are read-only for you: no add/commit/checkout/restore/reset/stash/clean/rebase/merge/push/tag/branch, no tracker mutations. Write only the files your task explicitly requires." Nobody ever runs checkout/restore/reset/clean/rebase, applies/pops/drops any stash other than this run's own recorded snapshot, or touches pre-existing stashes.
3. Commit authorization comes ONLY from the config's Commit section. Absent or NOT authorized → stop before committing, report the ready diff, and leave the tree for the user. The global no-autonomous-commit rule stays in force for everything except that one authorized end-of-run commit+push.
4. Write scope under `.claude/`: only `.claude/ocakbasi/` (and the one-time `.claude/ocakbasi.md` scaffold). Everything else this run touches must be the ticket's own source changes.
5. Halt-don't-improvise: a repo/tracker/state condition this file does not describe → log, notify, exit. Never invent recovery.
6. Context economy: never paste issue bodies, worker output, diffs, or command logs — summarize in ≤3 lines; run noisy commands with truncated output.

## State dir (`.claude/ocakbasi/` — self-ignoring: before first write, ensure `.claude/ocakbasi/.gitignore` exists containing `*`; create it if missing — never edit the project .gitignore)

- `queue.md` — the roadmap AND the cache in one file: a `fetched_at` header plus the ranked queue, one entry per known issue carrying number, title, updatedAt, labels, verdict (`ready` = autonomy gate passed at analysis time | `needs-grilling` | `dep-blocked` | `done` | `failed`), 1-line rationale, depends_on, completion sha. Rewritten only when something changed.
- `loop-log.md` — append-only history; one ≤7-line entry per run outcome; doubles as the done-list.
- `current.md` — the commit-gate token, exactly two fields (`state: idle|active`, `phase: commit|push|`), meaningful only around §Commit. Some machines gate autonomous `git commit/push` behind a hook keyed on it; writing it is harmless elsewhere.
- `artifacts//` — evidence the config declares (kept forever; overwritten if the same ticket re-runs; never committed).

## Main flow

### 1. Preflight
Read the config (missing → scaffold + stop). Reset a stale gate token to idle. If the config's runtime-check section defines backup/restore steps and a leftover backup exists (a prior run died mid-check), perform the restore now. Then:
- Tracker auth must pass (`gh auth status`).
- Dirty tree → halt: an idle run owns no changes; never stash or commit the user's work.
- Unpushed commit whose title matches the last loop-log entry's `(#N)` → push it now (§Commit token discipline) and continue; any OTHER unpushed commit → halt.
- Pull with rebase from the default branch — resolve it yourself, once: `git symbolic-ref --short refs/remotes/origin/HEAD` (strip `origin/`); unset → `git remote set-head origin -a`, re-read. Never assume a branch name. Conflict → abort the rebase, halt.
- Run the config's Preflight commands; failure there = the baseline itself is broken → halt without claiming a ticket.
- If the config's Commit section requires a gate hook, verify it is installed and registered; else halt with the config's pointer.

### 2. Select (cache-first — the token saver)
- ONE cheap paginated tracker list of ALL open issues — number, title, labels, updatedAt only, PRs excluded, no bodies (`gh api --paginate '.../issues?state=open&per_page=100'` with a `--jq` projection).
- Done-detection is local: a commit on the default branch whose title carries `(#N)`. Done = completion commit newer than the issue's updatedAt → excluded (the user closes it when satisfied). REWORK = updatedAt or a newer comment postdates the completion commit → re-queue with elevated priority; the post-completion comments (or, absent those, the current body incl. its Agent brief) become the implement brief.
- Cache hit = updatedAt unchanged in `queue.md` → reuse verdict/rationale/deps, NO body fetch. Only new/changed candidates need bodies+comments and dependency-direction analysis — read those INLINE (typically 0–2 per run; referenced issues too when a dependency's direction is unclear), condensing each straight into its ≤3-line queue.md entry.
- Recompute leaf/platform eligibility EVERY run from the cheap list (a dependency's open/labeled state changes without the candidate moving). The agent-ready label is a hard authorization boundary; the config's platform labels gate by this machine's OS; only LEAF candidates (no open blocking deps) are pickable.
- Dependency direction is inferred from issue text — mentions are often beneficiaries, not prerequisites; genuinely undecidable → treat as blocking, verdict `dep-blocked`, name the assumed edge in the report.
- Autonomy gate (on analysis): would open questions seriously change direction — architecture; user-visible behavior/policy; irreversible formats; perf-vs-quality tradeoffs with no stated budget; conflicts with committed project docs (CONTEXT.md, ADRs, plus the config's Docs extras)? Decisions recorded in the issue's Agent brief count as settled. Fails → verdict `needs-grilling` + the fork in one line; never ask, never write question files — /ocakbasi:grill-ticket is the resolution path (its body edit moves updatedAt, which re-queues naturally).
- Pick the top ready leaf. Nothing pickable → report the tally (done / needs-grilling / dep-blocked with one-liners) and exit.
- `dry-run` arg: stop here; report the selection + queue path; only `queue.md` was written.

### 3. Execute
Spawn ONE executor subagent (fresh context). First resolve THIS file's absolute path — `$CLAUDE_PLUGIN_ROOT/skills/consume-tickets/SKILL.md` via a Bash echo, or the path this skill was loaded from — then: "Read `` §Executor plus its Guardrails, and `.claude/ocakbasi.md`. Execute ticket #N. [REWORK: the post-completion comments are the brief.] Return only the contract line." Contract (≤10 lines): `done ` | `blocked ` | `needs-grilling ` | `failed `. The Agent tool itself erroring = `failed executor-died`.

### 4. Commit & push (main only, on `done`)
1. Write the gate token: `state: active`, `phase: commit`.
2. `git add -A`; commit per the config's Commit format. Self-check the message before pushing: format, length, no AI/assistant mentions, no body, no trailers — amend (message only) if violated.
3. Token `phase: push`; push. Non-fast-forward → ONE pull-rebase retry (conflict → abort the rebase; the commit stays local; report "push parked — rerun to retry").
4. Reset the token to idle.

### 5. Report
Append the loop-log entry: sha + title; gates result; runtime-check result; **awaiting your validation:** artifact paths + any user-judgment acceptance criteria; notes (fix rounds, flaky reruns). Update `queue.md` (verdict done, completion sha). One push notification line ("✅ #N  @" / "⏭ #N " / "🛑 ") — skip silently if the tool is unavailable. End with a short chat summary. Exit.

### §Failure (main, on `blocked` / `needs-grilling` / `failed`)
If the tree holds this run's changes → `git stash push -u -m "consume-tickets #N "` (never commit broken work, never discard it). Complete any restore step the config's runtime-check section defines (no leftover backups). `queue.md` verdict = failed or needs-grilling + 1-line reason (it stays excluded until the issue's updatedAt moves). Loop-log entry, notification, reset gate token, exit with the summary.

## §Executor (fresh subagent; bound by the Guardrails above at the EXECUTOR tier)

Run four phases in order; return ONE contract line.

a. **Implement** — directly in your own context by DEFAULT. Only when the Agent brief's Approach signals a wide blast radius (many components/subsystems) delegate to ONE nested worker (fresh context; worker git-contract verbatim; returns done/blocked in ≤10 lines) so your context stays lean for review. Either way: fetch the issue body+comments; an Agent brief in the body is the implementation contract — its Decisions bind, smallest change WITHIN that approach; a conflict between the brief and committed project docs (CONTEXT.md / ADRs / the config's Docs extras) → return `needs-grilling` with the conflict, never implement over either side. Follow the config's Verification policy; run the focused tests the change adds/touches.
b. **Review** — `git add -A` FIRST (untracked files must be inside the diff the review sees), record `git stash create` as the safety snapshot, then Skill `/code-review --fix` (no effort argument — it inherits the session's), explicitly scoped to ALL uncommitted changes vs HEAD with the `git status --porcelain` file list. `git add -A` again after its fixes. Work mass-reverted by a review agent → `git stash apply ` and note it. A CONFIRMED bug `--fix` could not fix → `failed review: `.
c. **Gates** — run the config's Gates commands in order via Bash with truncated output. On failure: ONE fix-round worker (gets the first error verbatim; forbidden from weakening or deleting tests), rerun the gates; max 2 rounds → `failed gates: `. A test that fails then passes on one full rerun = flaky: proceed and note it.
d. **Runtime check & artifacts** — only if the config has the section AND the diff has a runtime surface (the config defines what counts). Execute the section exactly as written: its backup/restore steps, each command via Bash with its configured timeout, its success signal, its error signatures, its kill/cleanup on timeout. Save declared artifacts under `.claude/ocakbasi/artifacts//` — `` in config commands resolves there; artifacts are user-validation evidence, never the acceptance path; keep them on failure too. A runtime error → fix rounds as in (c), rerunning the check, max 2 → `failed runtime-check: `. ALWAYS finish the section's restore steps, success or failure.

## Platform
Detect once: Darwin→macos, Windows→windows, else linux. Apply the config's platform-label convention when filtering candidates.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [osman-turan](https://github.com/osman-turan)
- **Source:** [osman-turan/skills](https://github.com/osman-turan/skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-osman-turan-skills-consume-tickets
- Seller: https://agentstack.voostack.com/s/osman-turan
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
