miadi-orchestration-kit

03 · Specify: Session Issue

Phase 3 (S). What to build, as prose code: a plugin of its own, claude/miadi-session-issue, with two hooks and one command, and one optional sink. Read with 02-intent.md and the kin file.

Session Issue gives a Claude Code session that asks for it one GitHub issue, opened from its first prompt and commented at each exit. People read, retitle and link sessions there like any other work.

Revised 2026-10-14. The first version of this file specified two hooks inside claude/miadi-session-observability, turned on per host by CHRONICLE_SESSIONS_REPO. Guillaume’s word the same day: “some of the session that I’m going to have, I will want them to create a GitHub issue from the first message and a comment on the exit. But I wouldn’t want it to be in any existing kit right now. I think it would be a new plugin.” So the issue is opted into per session, by a plugin of its own. The capture plugin keeps recording and never publishes. This plugin publishes, and only for a session that asked.

Desired outcome

A session that asks has one issue in a private repository, titled by its session id and first prompt. Each exit adds a comment with what the session did. A session that does not ask sees no change at all, on any host.

Current reality

Creative Advancement Scenarios

Creative Advancement Scenario: A session asked for at launch

User Intent: Guillaume starts a session he will want to find later, read and link to an episode. Current Reality: ilex has both plugins installed. His shell has alias claudeissue='MIADI_SESSION_ISSUE=1 claude'. Natural Progression Steps:

  1. He starts it with claudeissue. His first prompt reaches UserPromptSubmit. The opener sees the variable and no .issue_created, takes the lock, hands the work to a detached job, and returns without a word on stdout.
  2. The job checks that miadisabelle/chronicle-sessions is private and creates Session 3f2a9c1e: tidy the capture folder names. The body holds the session’s id, when and how it was opened, the folder, pane, team and episode, and the first prompt, sanitized.
  3. The URL lands in .issue_created, then a trace.log line, then a publication line. Achieved Outcome: The session has a page, found by its id, before the first answer arrives. Supporting Features: SessionIssueOpener, SessionIssueBody, RepositoryGuard, RepositoryChoice.

Creative Advancement Scenario: A session that turns out to matter

User Intent: Midway through a plain claude session, he decides it should have a page. Current Reality: The session did not ask at launch. Its first prompt is in the capture. Natural Progression Steps:

  1. He types /session-issue. The opener recognises the command, reads the session’s first prompt that is not the command (from _claude_user_inputs.jsonl, else from the transcript’s start), and opens the issue while the prompt waits.
  2. Its stdout, one line beginning miadi-session-issue:, names the link. The command tells the model to report that line and do nothing else. Achieved Outcome: The issue reads as if the session had asked from the start, and every later exit comments on it. Supporting Features: SessionIssueCommand, FirstPrompt.

Creative Advancement Scenario: A session’s story grows across days

User Intent: He resumes yesterday’s session, works, and exits twice in two days. Current Reality: .issue_created holds the issue URL from the first day. Today’s launch did not set the variable. Natural Progression Steps:

  1. The resumed session’s prompts find the marker, so the opener does nothing.
  2. Each /exit reaches SessionEnd. The commenter sees .issue_created, detaches and posts ## Session End: the reason (/exit), the session’s running totals, what it published since the previous comment (two commits, one push), and its last answer. Achieved Outcome: The issue reads as the session’s story, one comment per sitting. Supporting Features: SessionEndCommenter, PublishedSince.

Creative Advancement Scenario: A session that never asked

User Intent: jgi on gaia works as before, with the plugin installed. Current Reality: MIADI_SESSION_ISSUE is not set, and nobody types /session-issue. Natural Progression Steps:

  1. The opener checks the variable, the prompt text and .issue_optin, and returns. The commenter finds no .issue_created and returns. Achieved Outcome: No issue, no file, no network call. Supporting Features: OptIn.

Creative Advancement Scenario: A prompt carrying a secret

User Intent: A pasted command line holds a token. Current Reality: The capture sanitizer already redacts token shapes in every capture file. Natural Progression Steps:

  1. The opener passes the prompt through its bundled copy of that sanitizer before building the title and the body. Achieved Outcome: The issue shows the redaction marker the capture files show. Supporting Features: SessionIssueBody.

Creative Advancement Scenario: A decomposition run inside an asked session

User Intent: A claudeissue session runs miaco decompose, which starts claude -p steps. Current Reality: Each step inherits MIADI_SESSION_ISSUE, and Claude Code gives it CLAUDE_CODE_SESSION_ATTENDED=0. Natural Progression Steps:

  1. Each step’s opener finds itself headless, writes .issue_skipped with headless, and logs it once. Achieved Outcome: The asked session keeps its issue, and its steps open none. (A proposed default, held by Guillaume. MIADI_SESSION_ISSUE_HEADLESS=1 opens issues for them too.) Supporting Features: HeadlessRule.

Creative Advancement Scenario: The phone is offline

User Intent: He works on ilex with no network. Current Reality: gh cannot reach GitHub. Natural Progression Steps:

  1. The job’s gh call fails, so it writes Issue creation failed: …, counts one attempt and releases the lock.
  2. The next prompt tries again, up to three attempts. After the third failure the opener writes .issue_skipped with attempts and stops trying. /session-issue clears that and tries once more. Achieved Outcome: The session runs undisturbed. The capture folder holds the whole session, and trace.log says why there is no page. Supporting Features: SessionIssueOpener § Attempts.

Supporting structures

The two hooks advance, and do not oscillate, because each step leaves a file the next step reads:

Nothing is read back from GitHub but the repository’s visibility, nothing waits on GitHub but /session-issue, and nothing is retried after the session decided.

Components

OptIn

Decides, in the opener, whether anything is to be done. A session that did not ask costs one regular-expression match on the hook’s input and one stat.

RepositoryChoice

HeadlessRule

SessionIssueOpener

A UserPromptSubmit hook, hooks/first_prompt_issue.sh.

SessionIssueCommand

commands/session-issue.md, answered by the opener before the model reads it.

FirstPrompt

RepositoryGuard

SessionIssueTitle

SessionIssueBody

SessionEndCommenter

A SessionEnd hook, hooks/exit_comment.sh.

SessionEndComment

TracingSink (option, not built)

The same opening and closing, recorded as a trace that @miadi/tracing resolves. It is built only after a write path exists (kin file: @miadi/tracing, coaia).

Data

Configuration (environment)

| Name | Meaning | Default | |—|—|—| | MIADI_SESSION_ISSUE | Set at launch, the session asks. 1, or owner/repo to name the repository | unset: the session does not ask | | MIADI_SESSION_ISSUE_REPO | The host’s session repository, read before MIADI_CHRONICLE_SESSION_REPO. Set by binscripts etc/bash_env_common | unset | | MIADI_CHRONICLE_SESSION_REPO | The host’s session repository, set by binscripts etc/bash_env_common | unset | | MIADI_SESSION_ISSUE_HEADLESS | 1 opens issues for headless sessions that inherited the variable | unset | | MIADI_SESSION_ISSUE_SETTLE | Seconds the commenter waits for the capture’s last work | 2 | | MIADI_SESSION_ISSUE_SINKS, MIADI_SESSION_ISSUE_TRACE_DOMAIN | The tracing option, not built | github, eng | | CLAUDE_SESSIONDATA_ROOT, MIADI_SESSION_DIR, MIADI_SESSIONDATA_ROOT, SESSION_DATA_ROOT | The root, in the capture plugin’s order. Then /src/_sessiondata when it exists, then $CLAUDE_PLUGIN_DATA/sessions | the chain |

Files in <root>/<session_id>/

| File | Written by | Holds | |—|—|—| | .issue_created | opener | the issue URL, one line. The state indicator named in chronicle-sessions CLAUDE.md | | .issue_skipped | opener | headless, public <repo>, visibility <repo>, attempts or no repository: why this session has no issue | | .issue_attempts | opener | failed attempts, a number | | .issue_optin | /session-issue | the repository, until the next prompt opens the issue | | .issue_lock/ | opener | present while a job creates the issue | | .issue_comment_offset | commenter | publication lines already reported | | .trace_created | tracing sink | miadi-tracing:<domain>/trace/<id>, one line | | _session_issue_body.md, _session_end_comment.md | both | the last text posted, kept for reading | | trace.log | both | the lines named above, in the prototype’s words | | _claude_publications.jsonl | both | one line per issue or comment, by: "hook" |