···11+# Chainlink for Pi
22+33+Pi integration for [Chainlink](https://github.com/darienreese/chainlink) — a local issue tracker for AI coding sessions.
44+55+This folder contains two components:
66+77+| Component | Path | What it does |
88+|-----------|------|--------------|
99+| **Skill** | `chainlink/` | Teaches Pi how to use chainlink: commands, workflow, issue titles, sessions |
1010+| **Extension** | `chainlink-extension/` | Enforces chainlink usage: injects context, gates tool calls, detects stubs |
1111+1212+You can use the skill alone (lightweight, instructions only) or add the extension for full behavioral parity with the Claude Code integration.
1313+1414+---
1515+1616+## Skill — `chainlink/`
1717+1818+A [Pi skill](https://pi.dev/docs/skills) following the [Agent Skills standard](https://agentskills.io). Loaded on demand when you ask Pi about tasks, issues, or sessions.
1919+2020+**Install (project-local):**
2121+```bash
2222+cp -r chainlink .pi/skills/chainlink
2323+```
2424+2525+**Install (global):**
2626+```bash
2727+cp -r chainlink ~/.pi/agent/skills/chainlink
2828+```
2929+3030+**Use:**
3131+```
3232+/skill:chainlink
3333+```
3434+Or just ask Pi about tasks — it will load the skill automatically when relevant.
3535+3636+---
3737+3838+## Extension — `chainlink-extension/`
3939+4040+A [Pi extension](https://pi.dev/docs/extensions) (TypeScript) that ports the four Claude Code hooks:
4141+4242+| Claude Code hook | Pi event | Behaviour |
4343+|-----------------|----------|-----------|
4444+| `session-start.py` | `session_start` | Injects previous handoff notes and open issues at startup |
4545+| `prompt-guard.py` | `before_agent_start` | Injects code quality rules and project tree into every agent run |
4646+| `work-check.py` | `tool_call` | Blocks write/edit/bash when no chainlink issue is active |
4747+| `post-edit-check.py` | `tool_execution_end` | Warns when stub patterns are detected after file edits |
4848+4949+**Install:**
5050+5151+```bash
5252+cd chainlink-extension
5353+npm install
5454+cd ..
5555+5656+# Project-local
5757+cp -r chainlink-extension .pi/extensions/chainlink-extension
5858+5959+# Or global
6060+cp -r chainlink-extension ~/.pi/agent/extensions/chainlink-extension
6161+```
6262+6363+The extension reads rules from `.chainlink/rules/` (same directory structure used by Claude Code), so any rules you've already written work without changes.
6464+6565+---
6666+6767+## Requirements
6868+6969+- [Pi](https://pi.dev) installed
7070+- [Chainlink CLI](https://github.com/darienreese/chainlink) installed (`chainlink` on PATH)
7171+- A project initialised with `chainlink init` (creates `.chainlink/`)
7272+- Node.js 18+ (for the extension only)
7373+7474+---
7575+7676+## How it works
7777+7878+Chainlink stores issues in `.chainlink/issues.db` (SQLite). Both the skill and extension shell out to the `chainlink` CLI — no API keys or network access required.
7979+8080+The extension's `before_agent_start` handler reads language-specific rules from `.chainlink/rules/*.md` (e.g. `rust.md`, `typescript.md`) and appends them to Pi's system prompt, exactly as `prompt-guard.py` does for Claude Code. You can add project-specific rules to `.chainlink/rules/project.md`.
···11+---
22+name: chainlink
33+description: Issue tracking for AI coding sessions using chainlink. Use when starting work on a project, creating tasks, tracking progress, managing issues, or when the project has a .chainlink directory. Handles session management, issue lifecycle, subissues, dependencies, and handoff notes between sessions.
44+compatibility: Requires chainlink CLI installed. Install via: cargo install chainlink-tracker, or download a release binary from the project repository.
55+metadata:
66+ author: darienreese
77+ version: "1.0"
88+---
99+1010+# Chainlink Issue Tracker
1111+1212+Chainlink is a local SQLite-backed issue tracker built for AI coding sessions. Data lives in `.chainlink/issues.db`.
1313+1414+## Mandatory Workflow
1515+1616+**YOU MUST CREATE A CHAINLINK ISSUE BEFORE WRITING ANY CODE. NO EXCEPTIONS.**
1717+1818+1. Run `chainlink session start` at the start of a session (usually auto-started by the SessionStart hook)
1919+2. Create an issue BEFORE your first file edit or bash command: `chainlink quick "title" -p <priority> -l <label>`
2020+3. Mark focus: `chainlink session work <id>`
2121+4. Work, add comments as you discover things
2222+5. End with: `chainlink session end --notes "what was done, what's next"`
2323+2424+## Commands
2525+2626+```bash
2727+# Create and start working in one step (preferred)
2828+chainlink quick "Fix login validation error" -p medium -l bug
2929+3030+# Issues
3131+chainlink create "title" [-p high] [-d "desc"] [--label bug] [--work]
3232+chainlink list [-s all|open|closed] [-l label] [-p priority]
3333+chainlink show <id>
3434+chainlink update <id> [-t "new title"] [-d "new desc"] [-p high]
3535+chainlink close <id> # closes and adds to CHANGELOG.md
3636+chainlink close <id> --no-changelog
3737+chainlink reopen <id>
3838+chainlink delete <id>
3939+4040+# Hierarchy
4141+chainlink subissue <parent-id> "subtask title"
4242+4343+# Organization
4444+chainlink comment <id> "text" [--kind plan|decision|observation|result]
4545+chainlink label <id> <label>
4646+chainlink unlabel <id> <label>
4747+chainlink block <id> <blocking-id> # id is blocked by blocking-id
4848+chainlink unblock <id> <blocking-id>
4949+chainlink blocked # show blocked issues
5050+chainlink ready # show unblocked issues
5151+5252+# Sessions
5353+chainlink session start
5454+chainlink session status
5555+chainlink session work <id>
5656+chainlink session action "brief description" # breadcrumb before context compression
5757+chainlink session end --notes "handoff notes"
5858+chainlink session last-handoff
5959+```
6060+6161+## Issue Titles (Changelog-Ready)
6262+6363+Titles are auto-added to CHANGELOG.md when closed. Write them as:
6464+- Start with a verb: "Add", "Fix", "Update", "Remove", "Improve"
6565+- Describe the user-visible change, not implementation details
6666+- Example: "Fix authentication timeout on slow connections"
6767+- Bad: "auth.ts changes", "Fix bug", "WIP"
6868+6969+## Labels → Changelog Sections
7070+7171+| Label | CHANGELOG section |
7272+|-------|-------------------|
7373+| `bug`, `fix` | Fixed |
7474+| `feature`, `enhancement` | Added |
7575+| `breaking`, `breaking-change` | Changed |
7676+| `security` | Security |
7777+| `deprecated` | Deprecated |
7878+| `removed` | Removed |
7979+| (none) | Changed |
8080+8181+## Priority Guide
8282+8383+- `critical` — blocking other work, security issue, production down
8484+- `high` — user-requested, core functionality
8585+- `medium` — standard features, improvements
8686+- `low` — nice-to-have, cleanup
8787+8888+## Session Management
8989+9090+Sessions track what you're working on across context resets. **Always end sessions properly.**
9191+9292+End a session when:
9393+- The conversation is getting long (30–40 messages)
9494+- The user says goodbye or indicates stopping
9595+- You've completed a significant piece of work
9696+9797+Handoff notes must include: what was accomplished, what's in progress or blocked, and what to do next.
9898+9999+```bash
100100+chainlink session end --notes "Implemented retry queue (#3). Dead-letter table still needed (#4). Start with chainlink show 4."
101101+```
102102+103103+## Multi-Step Work
104104+105105+For features spanning multiple files or sessions:
106106+107107+```bash
108108+# Create epic + subissues
109109+chainlink create "Add user authentication system" -p high -l feature
110110+chainlink subissue 1 "Add registration endpoint"
111111+chainlink subissue 1 "Add login endpoint with JWT"
112112+chainlink subissue 1 "Add session middleware"
113113+114114+# Work one subissue at a time
115115+chainlink session work 2
116116+# ... implement ...
117117+chainlink close 2
118118+chainlink session work 3
119119+```
120120+121121+## Dependencies
122122+123123+```bash
124124+chainlink block 3 2 # Issue 3 is blocked by issue 2
125125+chainlink ready # Show what can be worked on now
126126+```
127127+128128+## Comments as Working Notes
129129+130130+Add typed comments as you discover things — these survive context compression and help future sessions:
131131+132132+```bash
133133+chainlink comment 1 "Found existing auth helper in utils/auth.ts — reuse it" --kind observation
134134+chainlink comment 1 "Decided to use JWT over sessions: stateless, fits the API design" --kind decision
135135+chainlink comment 1 "Next: wire up middleware to /api/protected routes" --kind plan
136136+```