---
name: neuralyzer
description: Use when the user explicitly invokes /neuralyzer, $neuralyzer, @neuralyzer, or /skill:neuralyzer to prepare a replacement project memory, review it, and restart a supported coding harness only after explicit approval.
disable-model-invocation: true
metadata:
  opencode/autoinvoke: false
---

# Neuralyzer

Forget what happened. Keep the context that matters. Believe this is where we started.

Neuralyzer is the Men in Black memory device for coding sessions. Agent K understands what happened, constructs a coherent replacement memory, presents it to the user, and performs the flash only after explicit approval.

This is a genuine fresh session, not conversation compaction. The new agent receives only the approved replacement memory as its conversational starting context.

## Supported harnesses

- Claude Code: `/neuralyzer`
- Codex: `$neuralyzer`
- OpenCode: `@neuralyzer`
- Pi: `/skill:neuralyzer`

The harness must be launched through `scripts/neuralyzer run <harness>` for approval and reset. In an unsupervised session, `propose` still preserves a draft in the OS temporary directory, but `approve` returns `NEURALYZER_RESET_UNAVAILABLE`. Never claim the context was erased.

## Non-negotiable guards

- Never reset automatically.
- Explicit approval of the exact proposed memory is mandatory.
- A request to modify, clarify, add, or remove information is not approval.
- If known background jobs, subagents, or tool calls are active, return `NEURALYZER_BACKGROUND_WORK_ACTIVE` and do not propose a flash.
- Never modify project source files, Git state, global preferences, or session history.
- Never delete the original conversation.
- Never invent facts. Unknowns stay explicit.
- Never run builds, tests, package managers, generators, or project scripts during verification.

Allowed verification is limited to file reads/searches and read-only Git queries such as `git status`, `git diff`, `git log`, `git ls-files`, and `git show`.

## Procedure

1. **Confirm supervision.** Check `NEURALYZER_SUPERVISED`, `NEURALYZER_STATE_DIR`, `NEURALYZER_SESSION_ID`, `NEURALYZER_AGENT`, and `NEURALYZER_GENERATION`. If unsupervised, continue through proposal only and explain that reset is unavailable.
2. **Check for active work.** If work is still running, stop with `NEURALYZER_BACKGROUND_WORK_ACTIVE`.
3. **Analyse.** Inspect the conversation and relevant project files. Separate verified facts from assumptions and discard obsolete decisions.
4. **Automatically construct the replacement memory.** Use `references/memory-template.md`. Write concise, actionable current reality; never write a narrative of the old conversation.
5. **Propose.** Save the draft without arming a reset:

   ```bash
   python3 <skill-dir>/scripts/neuralyzer propose --memory - <<'MEMORY'
   # Project Memory

   ## Objective
   ...
   MEMORY
   ```

   On Windows, use `py -3` instead of `python3`. Record the returned draft ID and hash.
6. **Present the complete proposal.** Show the entire memory in chat and explain that this is the context the new session will receive. Ask: “Reply APPROVE to use exactly this memory, or tell me what to change.”
7. **Review and revise.** If the user requests changes or provides an edited memory, create a new draft and present it again. Continue until the user explicitly approves or cancels. Never interpret an edit request as approval.
8. **Cancel when asked.** If the user declines, run `neuralyzer cancel --draft <draft-id>` and stop. The old session remains active.
9. **Approve only after confirmation.** Run:

   ```bash
   python3 <skill-dir>/scripts/neuralyzer approve --draft <draft-id>
   ```

   Approval binds to the exact draft hash and creates the immutable snapshot used by the fresh session.
10. **Flash.** If the command prints `NEURALYZER_ARMED`, run no more tools and end the turn immediately. The supervisor performs the graceful reset.
11. **Rebirth.** The fresh harness reads only the approved snapshot. It must not resume or receive the old conversation history.

## Memory rules

The replacement memory must:

- Be self-contained and concise.
- Describe current reality, not the path taken.
- Contain all eight required headings.
- Avoid phrases such as “earlier we discussed,” “previously the user decided,” or “in the previous conversation.”
- Never present discussed but unimplemented ideas as existing features.
- Keep the latest verified decision when older decisions conflict.
- Exclude secrets and credentials.
- Stay below 64 KiB.

## Failure behavior

- Invalid proposal: fix the validation errors and present a new draft.
- Modification request: revise and present again; do not approve.
- Cancellation: remove the draft and leave the current session running.
- Unsupervised session: preserve the draft and report `NEURALYZER_RESET_UNAVAILABLE` when approval is attempted.
- Active background work: report `NEURALYZER_BACKGROUND_WORK_ACTIVE`.
- Unsupported harness: report `NEURALYZER_UNSUPPORTED_HARNESS`.
- Reset failure: preserve the draft and approved snapshot, report the exact error, and never imply success.

The supervisor prints the flash banner only after a genuine fresh session has started:

```text
⚡ NEURALYZED — fresh session, clean memory
```
