# Mycelium Extra

**Use an LLM for analysis without handing it your judgement.** The agent proposes and runs. You decide what the analysis is. The record shows whether it ran that way.

Mycelium Extra keeps analysis decisions with the researcher. Before a run it shows each consequential choice with its source. After a run it shows where the record departs from the approved plan, and it shows an unchecked item as a gap. Whether researchers decide better or faster with it was not tested.

It is a plugin for Claude Code, Codex and OpenCode. It works alongside [Mycelium](https://github.com/arjunrajlaboratory/mycelium) or in an ordinary repository.

![A researcher states a question, an agent proposes a sourced plan, the researcher approves, covered work leaves records, and verification compares the records with the plan.](docs/figures/overview.svg)

## Before you start

You need an AI coding agent: Claude Code, Codex or OpenCode. You type to it in a terminal, inside your project folder, which should be a git repository. The plugin works with any language: an R script with DESeq2 goes through the same loop as the Python in the examples.

Five words recur on every page:

| Word | Means |
|---|---|
| gate | A check that runs before each command the agent tries, and denies a covered run that no approved plan names. |
| plan | A numbered table of steps, each choice marked with who made it. |
| card | A one-screen summary of the plan, shown for you to approve. Its 8-character **hash** names it. |
| receipt | A record the gate writes for each covered run: command, input files, exit status. |
| gap | Something nobody could check. Shown as a gap, never as a pass. |

## The loop

Each step has one page. Read them in order the first time.

| Step | You type | What you get |
|---|---|---|
| [Plan](docs/plan.md) | `/mycelium-extra:grill <question>` | A numbered plan. Every choice names who made it. Nothing runs. |
| [Approve](docs/approve.md) | `approve` | One card to read. Until you approve, the gate denies covered runs. |
| [Verify](docs/verify.md) | `/mycelium-extra:verify <hash>` | The run record set against the plan. Anything unchecked is a gap. |
| [Hand off](docs/handoff.md) | `/mycelium-extra:handoff` | A short file the next session starts from. |

Between Approve and Verify, you ask the agent to run the approved steps, as you would without the plugin. [Why it works this way](docs/why.md) gives the reasoning; the [walkthrough](docs/walkthrough.md) runs the whole loop on one simulated study.

## Install

Claude Code:

```bash
claude plugin marketplace add mdmanurung/mycelium-extra
claude plugin install mycelium-extra@mycelium-extra
```

Codex (CLI 0.160.0 or later). Then open `/hooks`, trust every Mycelium Extra hook and start a new task:

```bash
codex plugin marketplace add mdmanurung/mycelium-extra
codex plugin add mycelium-extra@mycelium-extra
```

OpenCode: point both settings at a checkout, in `~/.config/opencode/opencode.json(c)`:

```json
{
  "$schema": "https://opencode.ai/config.json",
  "plugins": ["/absolute/path/to/mycelium-extra/opencode"],
  "skills": ["/absolute/path/to/mycelium-extra/skills"]
}
```

Every host needs Python 3.12 or later. If your system `python3` is older (on RHEL 8 it is 3.6), set `MYCELIUM_EXTRA_PYTHON=python3.12` in your shell profile before you start the host. Restart the host after installing.

## Your first ten minutes

Claude Code and OpenCode use `/mycelium-extra:<skill>`. Codex uses `$mycelium-extra:<skill>`.

1. Run `/mycelium-extra:init` once in your repository. It turns on the gate by writing one file, `.mycelium-extra/gate.json`, and changes nothing else.
2. Run `/mycelium-extra:grill <your question>`. Answer its questions; it ends with a plan and a card.
3. Type `approve` as your whole message.
4. Ask the agent to run the plan, for example `Run steps 1 to 3 of the approved plan.` If a run is denied, the message says why; ask grill for a changed plan rather than working around it.
5. Run `/mycelium-extra:verify <hash>`, with the hash from the card.

```{toctree}
:hidden:
:maxdepth: 1

docs/why
docs/plan
docs/approve
docs/verify
docs/handoff
docs/walkthrough
Reference <docs/commands>
Changelog <https://github.com/mdmanurung/mycelium-extra/blob/main/CHANGELOG.md>
GitHub <https://github.com/mdmanurung/mycelium-extra>
```
