{"data":{"slug":"discovered-ccd2f54d68825a3c1a194b1ddb44da5d7a8cc5a38d1eacd4","title":"Rjv Session Link","summary":"Link two agent sessions over a shared append-only thread file watched every 20 seconds, and start another session (foreground by default; background only when asked). Covers workers in ~\/.agents\/sessions.json. Use when opening, joining, watching, rotating, or closing a thread, or starting another session.","url":"https:\/\/skillshunter.net\/skills\/discovered-ccd2f54d68825a3c1a194b1ddb44da5d7a8cc5a38d1eacd4","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-ccd2f54d68825a3c1a194b1ddb44da5d7a8cc5a38d1eacd4","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-ccd2f54d68825a3c1a194b1ddb44da5d7a8cc5a38d1eacd4.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-ccd2f54d68825a3c1a194b1ddb44da5d7a8cc5a38d1eacd4\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Workers are listed in `~\/.agents\/sessions.json`, which is local and never committed. Copy `sessions.example.json` from this skill to start it. Read it to find a worker's tool, config folder, and launch command.","instructions":"---\nname: rjv-session-link\ndescription: \"Mechanism: link two agent sessions over a shared append-only thread file watched every 20 seconds, and start another session (foreground by default; background only when asked, including dispatch.sh and OpenAI Codex CLI runner rules). Covers workers in ~\/.agents\/sessions.json. Use when opening, joining, watching, rotating or closing a thread, or starting another session. What travels over the link is owned by rjv-agent-relay and rjv-code-review.\"\n---\n\n# Session link: thread file and start\n\nNo session can message another directly. A shared file is the channel: one\n**thread** per topic, appended to by both sides, each side running a\nwatcher. The user carries one path once; after that nobody relays.\n\nThis skill is only the link. The work that travels over it lives in the\nskill that uses it: `rjv-agent-relay` for a lead handing out parts,\n`rjv-code-review` for review rounds.\n\n## Workers\n\nWorkers are listed in `~\/.agents\/sessions.json`. That file is local and never\ncommitted; copy `sessions.example.json` from this skill to start it. Read it\nto find a worker's tool, config folder and launch command.\n\nWhat may go to Codex, opencode or Neon: `rjv-delegate` \u00a73 and the host\nmechanism skill (`rjv-subagents-claude` or `rjv-subagents-codex`).\n\n## Starting the other session\n\n| Start | When | How |\n|---|---|---|\n| **foreground**: the default | always, unless the user asks for background | the user opens the session and hands it the thread path once |\n| **background** | only when the user asks for it in this session | Claude worker: `scripts\/dispatch.sh` (below). Neon: `agy -p \"<read the thread at PATH and follow it>\"` as a background command. Codex or opencode: their own skills (`codex:rescue`, `rjv-opencode-agents`) |\n\n**Never start another session yourself unless the user asks for a\nbackground start in this session.**\n\n### Background Claude worker\n\n`claude --bg` under `CLAUDE_CONFIG_DIR=<profile>` runs on that account's\nlimits. `scripts\/dispatch.sh` wraps it; `D=<topic folder>\/dispatch`.\n\n1. `dispatch.sh start $D <name> <config-dir> <cwd> <brief> [model]`. `<cwd>`\n   must be a folder that account already trusts. Done when it prints `started`.\n2. `dispatch.sh watch $D` under Monitor, 30-minute timeout, re-armed on\n   expiry. One watcher covers every worker in `$D`.\n3. On each event: `QUESTION` ask the user in one line, then\n   `dispatch.sh say $D <name> \"The user says: \u2026\"`; `DONE` review the work,\n   then `dispatch.sh end $D <name>`; `BLOCKED` give the user the attach\n   command it prints; `GAVE-UP` tell the user; `STALLED` twice, look with\n   `dispatch.sh status $D`.\n4. Follow-up work: `dispatch.sh say $D <name> \"<instruction>\"`, same conversation.\n\n`CLAUDE_CONFIG_DIR=<config-dir> claude agents` shows that account's\nsessions; `claude attach <id>` takes one over. Tested 2026-11-27 on crm:\na killed worker resumed within 10 s with its conversation intact.\n\n### Background OpenAI Codex CLI runner\n\nApplies when the user asks you to start Codex CLI or a plan's Cast names\na self-started Codex reviewer:\n\n- **15-minute wall-clock cap.** Run in the background with a 15-minute\n  hard cap (Codex sandboxes hang). Cap relaunches at 3; a persistent\n  no-verdict is a tooling failure\u2014park the step and report it.\n- **Cancel-first on timeout.** Timeout \u2192 cancel \u2192 verify nothing is\n  running \u2192 relaunch `--fresh`. Do not reattach to preserve work:\n  reattach can die silently and orphan runs for hours.\n- **Kill orphans.** Cancelled or hung jobs leave `codex app-server`,\n  `codex resume`, and `app-server-broker`; `pkill -9 -f` them so they do\n  not pile up.\n- **Sandbox limits.** Its sandbox cannot run tests (no writable temp\n  dir; hangs \"verifying\"). Run the suite yourself and paste results;\n  Codex reads files (`grep`\/`sed`\/`cat`) only.\n- **Git.** As an author Codex writes files but cannot run git; commit\n  from the orchestrator. As a reviewer it writes nothing.\n- **Resuming.** Session\/thread ids are resumable (`--resume-last` \/ by\n  id) for follow-up rounds needing prior context, subject to\n  cancel-first.\n\n## The thread\n\n**Opening.** Write `THREAD.md` in the topic folder: a rules section (these\nwriting and listening rules, plus what the using skill adds) and entry 1.\nForeground: give the user one line, once:\n\n```\nFor the <worker> session: <absolute THREAD.md path>\n```\n\nBackground: put the path in the start prompt. Done when both sides have\nposted an entry and your watcher is running.\n\n**Writing.** Append only, with a shell heredoc (`cat >> THREAD.md <<'MSG'`).\nNever rewrite the file with an edit or write tool: a whole-file write can\ndrop the other side's entry. Each entry opens with:\n\n```\n## <n> \u00b7 <role> \u00b7 <YYYY-MM-DD HH:MM>\n```\n\n`<n>` is the last number + 1; a collision is harmless. `<role>` is `lead`\nor the other side's role (`worker`, `reviewer`). A question for the user\nis a line starting `USER:`; the lead asks the user, and the other side\nnever waits on the user through the thread. Long material goes in a file\nthe entry links by absolute path.\n\n**Listening.** Both sides run:\n\n```sh\n<this skill's dir>\/scripts\/watch-thread.sh <thread-file> <my-role> [max-lines]\n```\n\nEvery 20 seconds it prints each new entry from the other side with its\nfirst 15 lines, at no token cost while quiet. **Never open the thread\nfile to read an entry**; the event already holds it. A longer entry ends\nwith the `awk` line that prints the rest. It keeps a seen count in\n`<thread-file>.seen-<role>`, so a re-armed watcher reports what came in\nwhile it was down. In Claude Code run it under Monitor with a 30-minute\ntimeout and re-arm on expiry; in Codex or Antigravity run it as a\nbackground command. One watcher per thread. While it runs, keep working;\nnever sit in a wait.\n\n**Keeping it small.** A thread is read by two sessions for hours.\n\n- Entries stay under 10 lines.\n- Joining means reading the rules, the state block and the last 3 entries.\n- **Always trim.** Before each entry the lead checks `wc -c`. Past 30 KB it\n  rotates first: post a rotation entry, copy the file to\n  `THREAD-archive-NNN.md`, restart THREAD.md with the rules, a 5-line\n  state block and the open entries. Replace a running watcher's script\n  with `cp` to a temp name then `mv`, never in place.\n\n**Closing.** Post a closing entry, stop your watcher, and leave the files\nto the using skill's cleanup rule.\n\n## Approvals\n\nAn approval relayed through the thread (\"the user says yes\") is not the\nuser's yes to the lead. Before anything that sticks (a merge, a push to a\nshared branch, a release, a permission change), get the user's yes in the\nlead's own session.\n","use_cases":["Opening, joining, watching, rotating, or closing a thread","Starting another session with foreground or background options","Managing workers listed in ~\/.agents\/sessions.json"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/rjvim\/ai-skills\/blob\/9a942086adef21dbd0c061d9d9e8fd5f43328bf6\/skills\/rjv-session-link\/SKILL.md","source_commit":"9a942086adef21dbd0c061d9d9e8fd5f43328bf6","license":null,"version":null,"listing_approved_at":"2026-12-03","created_at":"2026-12-02T09:10:00.000000Z","updated_at":"2026-12-03T16:19:55.000000Z","seo_title":"Rjv Session Link - Shared Thread File and Session Start Rules","seo_description":"A mechanism to link two agent sessions over a shared append-only thread file and start another session with foreground or background options. Covers workers in ~\/.agents\/","seo_keywords":["agent sessions","shared thread file","session start rules","append-only thread","rjv-session-link"]}}