skills/coding-session/SKILL.md
Autonomous coding workflow: branch, code, test, draft PR. Use when starting a coding task from the idle loop or continuing an incomplete session. Keywords: coding, implement, fix, bug, PR, CI, test, review, worktree, autonomous
npx skillsauth add avifenesh/cairn coding-sessionInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Workflow for coding tasks submitted by the idle loop. You're in an isolated worktree with your own branch.
cairn.loadSkill with go-dev, pr-workflow, etc.# Your worktree already has a cairn/{taskID} branch
# Rename it to something meaningful:
cairn.gitRun: ["branch", "-m", "feat/cairn-<short-description>"]
# or: fix/cairn-<short-description>
cairn.readFile → understand existing codecairn.editFile → make targeted changescairn.shell → run tests: go test ./...cairn.shell → check quality: go vet ./..., gofmt -l .cairn.gitRun: ["add", "file1.go", "file2.go"] # specific files, never -A
cairn.gitRun: ["commit", "-m", "fix: descriptive message"]
cairn.shell: "git push -u origin HEAD"
NEVER push to main or master. cairn.gitRun blocks this.
cairn.shell: "gh pr create --draft --title 'Short description' --body '## Summary\n- What was changed\n- Why\n\n## Test plan\n- [ ] go test ./... passes\n- [ ] go vet clean'"
CRITICAL rules:
--draft — never ready-for-reviewgh pr merge — blocked by policy. Only the repo owner can merge.agent-cairn — your PRs are identified by this GitHub identityThis loop runs until BOTH conditions are met: CI green AND 0 unresolved review threads. Do NOT exit the coding session until this loop completes.
Max iterations: 10. Initial reviewer wait: 180 seconds (3 minutes).
iteration = 0
while iteration < 10:
iteration += 1
# Step A: Wait for CI to complete (poll every 60s, max 15 polls)
poll = 0
while poll < 15:
cairn.shell: "sleep 60 && gh pr checks <number>"
poll += 1
# If all checks completed (no "pending"): break
# If any check failed:
# 1. Get failure logs: cairn.shell: "gh run view <run-id> --log-failed"
# 2. Fix the issue
# 3. Commit + push
# 4. Continue loop (CI will re-run)
# Step B: Wait 180s for auto-reviewers after every push (not just first).
# Auto-reviewers re-analyze after EVERY push. They need time.
cairn.shell: "sleep 180"
# Step C: Check for unresolved review threads
cairn.shell: "gh api graphql -f query='query($owner:String!,$repo:String!,$pr:Int!){repository(owner:$owner,name:$repo){pullRequest(number:$pr){reviewThreads(first:100){nodes{isResolved}}}}}' -f owner=OWNER -f repo=REPO -F pr=<number> --jq '[.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false)] | length'"
# Step D: If 0 unresolved → quiet period check
if unresolved == 0:
# MANDATORY: wait 3 minutes for late comments from auto-reviewers.
cairn.shell: "sleep 180"
# Re-check: run the SAME GraphQL query from Step C again
unresolved_after_wait = <result of same query>
if unresolved_after_wait == 0:
break # truly clean — exit loop
# else: new comments arrived — fall through to Step E
# Step E: Address ALL comments
# E1. Fetch unresolved thread IDs + comment bodies:
cairn.shell: "gh api graphql -f query='query($owner:String!,$repo:String!,$pr:Int!){repository(owner:$owner,name:$repo){pullRequest(number:$pr){reviewThreads(first:100){nodes{id,isResolved,comments(last:1){nodes{body,path,line}}}}}}}' -f owner=OWNER -f repo=REPO -F pr=<number> --jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false) | {threadId: .id, comment: .comments.nodes[0]}'"
# E2. Fix every comment — high, medium, AND low priority. No skipping.
# E3. Resolve each thread after fixing:
cairn.shell: "gh api graphql -f query='mutation($id:ID!){resolveReviewThread(input:{threadId:$id}){thread{isResolved}}}' -f id=<threadId from E1>"
# E4. Commit + push:
cairn.gitRun: ["commit", "-m", "fix: address review feedback (iteration N)"]
cairn.shell: "git push"
# Step F: Brief pause before next iteration (CI re-triggers on push)
cairn.shell: "sleep 30"
EXPECT 5+ ITERATIONS. This is normal. Auto-reviewers post new comments after every push. The loop only exits when: CI green AND 0 unresolved AND 3-minute quiet period passed with no new comments.
When the loop exits clean:
cairn.shell: "gh pr ready <number>" # Remove draft status
When PR is ready and all reviews addressed:
cairn.publishToFeed: message="PR ready: <title> — CI green, all reviews addressed, quiet period clean. Review at <url>", priority=medium
The session is COMPLETE only after:
Output: [SESSION_COMPLETE] PR #<number> — CI green, 0 unresolved, quiet period clean, ready for merge.
If you're approaching the round limit (check current round vs 400 max) and the CI/review loop is not done:
cairn.createCron: name="pr-watch-{owner}-{repo}-<PR_NUMBER>", schedule="0 * * * *", instruction="Continue PR #<PR_NUMBER> review loop. Check CI + unresolved comments. Fix issues and push. Delete this cron when PR is merged/closed."
CRITICAL — stale worktree paths are the #1 source of tool errors (~1,500+/period).
/home/ubuntu/cairn-540, /tmp/wt-573) — those worktrees no longer exist./home/ubuntu/cairn/internal/foo.go or /tmp/cairn-worktrees/sub-xyz/internal/foo.go — use internal/foo.go instead.internal/tool/builtin/gog.go, not /tmp/wt-578/internal/tool/builtin/gog.go.pwd of your shell session), not from memory or prior sessions.pwd via cairn.shell — the output IS your root.gofmt -w . for Go, pnpm check for frontenddata-ai
Detect agent-cairn PRs that have stalled (no activity >=90 min) and classify the failure mode to route to appropriate recovery agent.
tools
Post-install skill adaptation: read a newly installed SKILL.md, fix environment-specific references (paths, accounts, tool names), assign the skill to relevant agent types, and propose an AGENTS.md update. Triggered automatically after cairn.installSkill completes.
data-ai
Monthly self-improvement brief for Cairn. Queries error_patterns, action_exemplars, experiment_windows, and session_journal to synthesize what Cairn learned, where it failed, and 3 concrete proposals for Avi to approve. Run on the 1st of each month. Keywords: growth brief, monthly review, self-improvement, what did cairn learn, how is cairn doing, monthly report
testing
Decision support with memory-backed context. Retrieves past decisions, journal history, and relevant facts before answering questions that involve a choice or tradeoff. Keywords: should I, which is better, tradeoff, compare, decide, choose, option, alternative, pros and cons, recommend