KeiSeiKit-1.0/skills/sleep-setup/SKILL.md

5 KiB

name description argument-hint
sleep-setup One-time wizard (RULE 0.15) that configures KeiSeiKit v0.11 cloud REM sync. Generates an SSH deploy key, initializes the user's memory-repo, writes env refs (RULE 0.8), and emits a ready-to-paste `/schedule create` command for nightly consolidation. Pure-click except the 1 free-text field for repo URL. (no arguments)

Sleep Setup — Cloud REM Sync Wizard (index)

You are running the one-time configuration wizard for the KeiSeiKit v0.11 sleep layer. Each session-end dump pushes to a private git repo; a cloud Claude Code agent on /schedule clones the repo nightly, analyzes traces, and commits a consolidation report back. In the morning the user runs git pull and reads the report. Nothing in this pipeline blocks session close, and report content is for the user to READ — never auto-injected.

This SKILL.md is the INDEX. Each phase lives in its own file and is executed in order. Never skip a phase. Never re-order phases.


Pipeline overview (6 phases, 9+ AskUserQuestion since v0.13.0)

Phase File Purpose AskUserQuestion
1 phase-1-repo-pick.md Pick repo provider + visibility 2 (click-only)
2 phase-2-repo-url.md Collect SSH URL (1 free-text field) 1 (AskUserQuestion freeText)
3 phase-3-deploy-key.md Run kei-sleep-setup.sh, show pubkey, confirm deploy-key added 1 (click)
3b phase-3b-deep-sleep.md v0.13.0 — deep-sleep cadence + fork mode + store backend 3 (click; +1 free-text if Custom cadence)
4 phase-4-test-push.md Dry-run a test commit via kei-sleep-sync.sh 1 (click)
5 phase-5-trigger.md Render /schedule create command, offer to run now 1 (click)

Minimum AskUserQuestion count: 9. All clicks except the single repo-URL free-text in Phase 2 (plus optional Custom cadence / S3 fields in Phase 3b).


Variables the pipeline produces

Name Set in Meaning
PROVIDER Phase 1 github / gitlab / bitbucket / self-hosted
VISIBILITY Phase 1 private (recommended) / public (explicit user choice)
REPO_URL Phase 2 Validated SSH URL (git@host:org/repo.git)
KEY_ADDED Phase 3 boolean; was deploy key confirmed added?
DEEP_SLEEP_CRON_DAYS Phase 3b integer ≥0; 0 disables Phase C; default 7
DEEP_SLEEP_WITH_FORK Phase 3b 0 (plan only) / 1 (plan + fork branch)
STORE_BACKEND Phase 3b github / forgejo / gitea / filesystem / s3
TEST_VERIFIED Phase 4 boolean; did the user see the test commit in the remote?
SCHEDULE_ACTION Phase 5 run-now / copy-later / skip

Final report (emit after Phase 5)

=== SLEEP-SETUP REPORT ===
Provider:       <PROVIDER> (visibility: <VISIBILITY>)
Repo URL:       <REPO_URL>
Deploy key:     ~/.ssh/keisei-memory-sync(.pub)
Sync repo path: ~/.claude/memory/sync-repo/
Env refs:       ~/.claude/secrets/.env  (KEI_MEMORY_REPO_URL, _PATH, _SSH_KEY)
Test push:      <PASS/FAIL> (Phase 4)
Schedule:       <SCHEDULE_ACTION>

If SCHEDULE_ACTION == skip, add:

Local-only mode. Traces will be pushed to the repo on every session end.
To enable nightly consolidation later: paste the prompt from Phase 5 into
`/schedule create` any time.

Rules (apply throughout — enforced at every phase)

  • Pure-click contract. Only Phase 2 asks for free text; every decision is an AskUserQuestion. No freeText outside Phase 2.
  • Idempotent. Re-running the wizard must NOT clobber existing ~/.ssh/keisei-memory-sync or ~/.claude/memory/sync-repo/; the helper script handles re-use.
  • NO DOWNGRADE (RULE -1). If SSH auth fails, return 2-3 constructive paths (re-check deploy key, check sshd host, fall back to HTTPS with PAT — with warning) — never "cannot set up".
  • NO HALLUCINATION (RULE 0.4). Never fabricate repo URLs, key fingerprints, or commit hashes. Show the real output of the script.
  • RULE 0.8 secrets. The wizard writes env-var REFERENCES to ~/.claude/secrets/.env, never inline tokens in any generated file.
  • RULE 0.1 private remotes. Recommend private visibility in Phase 1. If the user explicitly picks public, warn once: "a public memory repo leaks your session prompts and tool usage — confirm?".
  • Silent failure (RULE 0.15). Nothing in the session-end path may block the session from closing. The wizard itself may fail loudly.
  • Constructor Pattern (RULE ZERO). Every phase file < 100 LOC (well under the 200-LOC file limit).

References

  • ~/.claude/rules/sleep-layer.md — RULE 0.15 full text
  • ~/.claude/rules/secrets-single-source.md — RULE 0.8 enforcement
  • _primitives/kei-sleep-setup.sh — the imperative setup helper
  • _primitives/kei-sleep-sync.sh — the session-end-dump callback
  • _primitives/templates/sleep-trigger-prompt.md — cloud agent prompt
  • hooks/session-end-dump.sh — where kei-sleep-sync.sh is invoked