---
name: lavish-keeper
description: Keeps the Lavish review listener (lavish-axi poll) alive across Claude Code sessions. Use when a SessionStart message from lavish-keeper asks to restart a poll, when the user says the Lavish listener dropped ("caiu a escuta", "the poll died", "notes are not arriving"), or to inspect which pages a session was watching.
version: "0.1.0"
metadata:
  author: Lucas Saldanha Werneck <lucas@2olhares.com>
  tags: [lavish, lavish-axi, poll, hooks, sessions]
---

# lavish-keeper

## Purpose

Lavish pages are reviewed by a person who sends notes back through `lavish-axi poll`. That poll is a command of the Claude session: when the session closes, the listener goes away and nobody is reading notes. lavish-keeper remembers which pages each session opened, stops the leftover polls when the session closes, and when the session opens again tells the agent to start the polls again.

## Instructions

1. When a SessionStart message from lavish-keeper lists `npx -y lavish-axi poll <file> --owner <label> --takeover`, run each command as its own tracked background Bash command (`run_in_background: true`). Do this before anything else in the turn, then carry on with the user's request.
2. If a page has queued notes, the poll returns them at once. Read the whole output, save the notes to a file, say how many you read, and only then change anything.
3. Do not tell the user a page is being watched until its background poll is running.
4. A page the user ended is not listed. Never reopen it without being asked.
5. To see what is remembered: `python3 "${CLAUDE_PLUGIN_ROOT}/bin/lavish-keeper" list`. To drop a session's pages: `... forget <session-id>` or `forget --all`.

## Prerequisites

- Python 3.8+, `lavish-axi` (run through `npx -y lavish-axi`), and a Claude Code that fires SessionStart, SessionEnd and PostToolUse hooks (terminal and desktop app).
- `pgrep` for stopping leftover polls (macOS and Linux). Without it, restarting still works through `--takeover`.

## Limitations

- It cannot wake an idle session by itself: only a background command of the agent can do that, which is why the restart is done by the agent after the hook asks for it. A closed session is not woken by a note; the notes wait in Lavish until the session opens again.
- Pages are matched to a session by the `lavish-axi` commands the session ran through the Bash tool. A page opened outside a session is not tracked.
- After `/clear` the session id changes; pages pass to the new session if it starts in the same folder within 15 minutes.

## Troubleshooting

- `LISTENER_ACTIVE` from a poll: another poll still holds the page. Re-run with `--takeover` (the hook's command already has it).
- The agent was not asked to restart anything: `lavish-keeper list` shows nothing for the session, so no `lavish-axi` command went through Bash in it, or the page was ended in Lavish.

## Examples

- Session closed with a page open, reopened later: the SessionStart message lists the page; the agent runs `npx -y lavish-axi poll /path/page.html --owner claude-1a2b3c4d --takeover` in the background.
- "what was this session watching?": `lavish-keeper list`.
