<!-- source: https://cli.dreamlake.ai/dev/claude-code-skill @ 0.134.0 99837ab -->

# `/dreamlake` Claude Code skill

Typing `/dreamlake` inside a running Claude Code session registers that session
with DreamLake before the model sees the prompt, prints the **saved session ID**
and the `dl sessions control send` recipe, and writes a private env file
that any other shell can `source` so its memo and artifact writes link to the
same session. The CLI side is `dl sessions register --write-env`
([registration and visibility](/sessions.md#registration-and-visibility-0820)); the
skill is one shell line around it.

Skills are owned by the public
[dreamlake-skills](https://github.com/dreamlake-ai/dreamlake-skills) repository
and this repository never generates them. Until the skill lands there, this
page is the spec: copy the block below to `~/.claude/skills/dreamlake/SKILL.md`
(personal) or `.claude/skills/dreamlake/SKILL.md` (per project). It needs the
CLI release that ships `--write-env` and the `CLAUDE_CODE_SESSION_ID` fallback.

## SKILL.md

```markdown
---
name: dreamlake
description: Register this Claude Code session with DreamLake so people and the built-in agent can see it, message it with `dl sessions control send`, and so the notes and artifacts it writes link back to it. Use when the user types /dreamlake or asks to put this session under DreamLake.
allowed-tools: Bash(dl sessions:*)
---

# This session under DreamLake

!`dl sessions register --provider claude --session "${CLAUDE_SESSION_ID:-$CLAUDE_CODE_SESSION_ID}" --cwd "$PWD" --visibility private --write-env "$HOME/.dreamlake/sessions/${CLAUDE_SESSION_ID:-$CLAUDE_CODE_SESSION_ID}.env" 2>&1`

The output above is the registration receipt. Tell the user, in two lines:

1. the saved session ID and that the session is private;
2. the exact `dl sessions control restart … --raise` and
   `dl sessions control send <id> "…"` lines printed above, noting
   that they need `dl sessions serve --max-human-permission …` running
   on this machine and that the restart is typed once, by the person.

Rules:
- Registration is idempotent: running `/dreamlake` again returns the same
  saved ID; never register a second time with a made-up UUID.
- Note and artifact writes made by this session's own commands already link
  automatically through `CLAUDE_CODE_SESSION_ID`. The env file is for other
  shells: `source "$HOME/.dreamlake/sessions/<native-uuid>.env"`.
- If the receipt says "Log in" or "Not logged in", run `dl login`
  first; do not retry the registration in a loop.
- Do not change the visibility of the session unless the user asks.
```

### How it works

- The `` !`…` `` line is Claude Code's dynamic-context syntax: the command runs
  in the session's shell **before** the prompt reaches the model and its output
  replaces the placeholder. Claude Code exports `CLAUDE_CODE_SESSION_ID` to the
  commands it runs; the fallback expression also honours an explicit
  `CLAUDE_SESSION_ID`.
- `dl sessions register` posts the provider and native UUID to
  `/terminal-sessions/register`, which returns the existing saved row when one
  matches, so the line is safe to run on every invocation.
- `--write-env` writes `export DREAMLAKE_TERMINAL_SESSION_ID='…'` and
  `export DREAMLAKE_SESSION_NAMESPACE='…'` with mode 600. The assignments are
  exported, so `source`-ing the file passes the pair to every `dreamlake`
  process that shell starts. That pair is the explicit saved-session context
  the CLI reads first, before any native id, so a shell that sources it links
  its writes without a lookup.
- The plain (non-`--json`) output is written for the model: saved ID,
  namespace, visibility, the `control send` and `control status` recipes.

## Codex mirror

Codex skills cannot run shell before the prompt. The Codex skill carries the
same text with an instruction block instead of the `` !`…` `` line: the model
runs `dl sessions register --provider codex --session "$CODEX_THREAD_ID"
--cwd "$PWD" --visibility private --write-env "$HOME/.dreamlake/sessions/$CODEX_THREAD_ID.env"`
itself and reports the receipt. `CODEX_THREAD_ID` is the native id Codex
exports; the CLI already reads it for automatic affiliation.

## Zero-typing variant: a SessionStart hook

To register every Claude Code session without typing anything, add a
`SessionStart` hook in `~/.claude/settings.json`. Hooks receive the session id
on stdin as JSON, so the hook does not depend on the environment variable:

```json
{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "sid=$(jq -r .session_id) && dl sessions register --provider claude --session \"$sid\" --cwd \"$PWD\" --visibility private --write-env \"$HOME/.dreamlake/sessions/$sid.env\" --json >/dev/null 2>&1 || true"
          }
        ]
      }
    ]
  }
}
```

The `|| true` keeps a logged-out CLI or an offline network from blocking the
session start; the skill remains the way to get the recipe printed on demand.

## Verifying an installation

1. In a Claude Code session, type `/dreamlake`. The reply names a 24-hex saved
   ID and a `sessions control send` line.
2. `dl sessions show <saved-id> --namespace <ns>` shows provider
   `claude`, the native UUID and `private`.
3. Type `/dreamlake` again: the same saved ID comes back.
4. `cat "$HOME/.dreamlake/sessions/<native-uuid>.env"` holds the two variables
   and is mode `600`; in another terminal, `source` it and create a note:
   `dl sessions resources <saved-id> --namespace <ns>` lists that memo.
5. With `dl sessions serve --max-human-permission workspace-write`
   running on the machine, record the level once, on a terminal:
   `dl sessions control restart <saved-id> --permission workspace-write --raise --namespace <ns>`
   (a registered session has no recorded level, and a runner refuses a turn
   without one). Then
   `dl sessions control send <saved-id> "Summarize your state" --namespace <ns>`
   returns a receipt with the session's reply (headless) or `delivered: true`
   (tmux).
