--- name: weekly-digests description: Generate a serial week-by-week narrative digest of a project's full claude-mem timeline. Splits the timeline into per-ISO-week files, then runs one consecutive subagent per week — each receiving the prior week's carry-forward block — to produce one chapter per ISO week of data. Use when asked for "weekly digests", "week-by-week story", "serial timeline", or "narrative chapters" of a project's history. --- # Weekly Digests Produce a serial, multi-chapter narrative digest of a project's complete claude-mem history. Differs from `timeline-report` (one long report) — this generates one digest *per ISO week*, with each subagent reading the prior week's carry-forward block so the story stays coherent. **The chapter count equals the number of ISO weeks the timeline covers.** A project with 2 weeks of data produces 2 chapters; one with 30 weeks produces 30. There is no fixed length — count the weeks first, then drive the pipeline off that count. ## When to Use Trigger when the user asks for: - "Weekly digests" - "Week-by-week story" - "Serial timeline" - "Story chapters of [project]" - "Run a digest for each week" - "Continue the story week by week" If the user wants a single sweeping report, use `timeline-report` instead. This skill is for serial chapter format. ## Prerequisites - claude-mem worker running - Project has at least one ISO week of observations (the pipeline degenerates gracefully — even N=1 works) - A clean output directory the user is comfortable writing into **Resolve the worker port** (do this once, reuse `$WORKER_PORT`): ```bash WORKER_PORT="${CLAUDE_MEM_WORKER_PORT:-$(node -e ' const fs = require("node:fs"), path = require("node:path"); const home = require("node:os").homedir(); const windows = process.platform === "win32"; let dir = process.env.CLAUDE_MEM_DATA_DIR || path.join(home, ".claude-mem"); if (dir === "~") dir = home; else if (dir.startsWith("~/") || (windows && dir.startsWith("~\\"))) { dir = path.join(home, dir.slice(2)); } let port; try { const doc = JSON.parse(fs.readFileSync(path.join(dir, "settings.json"), "utf8").replace(/^\uFEFF/, "")); const env = doc?.env; const settings = env && typeof env === "object" && !Array.isArray(env) && Object.keys(env).some(key => key.startsWith("CLAUDE_MEM_")) ? env : doc; port = settings?.CLAUDE_MEM_WORKER_PORT; } catch {} // Keep the default in step with src/shared/install-port.ts. if (!port) { const uid = process.getuid?.(); const folder = windows ? path.win32.resolve(dir).toLowerCase() : path.resolve(dir); const offset = uid === undefined ? require("node:crypto").createHash("sha256").update(folder, "utf8").digest().readUInt32BE(0) % 100 : ((uid % 100) + 100) % 100; port = 37700 + offset; } process.stdout.write(String(port)); ' 2>/dev/null)}" ``` ## Workflow ### Step 1: Determine the Project Name Same worktree-detection pattern as `timeline-report`. In a worktree, the data source is the **parent project**: ```bash git_dir=$(git rev-parse --git-dir 2>/dev/null) git_common_dir=$(git rev-parse --git-common-dir 2>/dev/null) if [ "$git_dir" != "$git_common_dir" ]; then parent_project=$(basename "$(dirname "$git_common_dir")") else parent_project=$(basename "$PWD") fi echo "$parent_project" ``` ### Step 2: Fetch the Full Timeline and Save It ```bash ( mkdir -p .scratch || exit 1 timeline_tmp=$(mktemp .scratch/cm-timeline.md.XXXXXX) || exit 1 trap 'rm -f "$timeline_tmp"' EXIT if ! http_status=$(curl -sS --no-location -o "$timeline_tmp" -w '%{http_code}' \ "http://localhost:${WORKER_PORT}/api/context/inject?project=PROJECT_NAME&full=true"); then echo "Timeline fetch failed." >&2 exit 1 fi if [[ "$http_status" != 2[0-9][0-9] ]]; then echo "Timeline fetch failed (HTTP $http_status)." >&2 exit 1 fi if [ ! -s "$timeline_tmp" ]; then echo "Timeline fetch returned an empty body." >&2 exit 1 fi if [ -d .scratch/cm-timeline.md ]; then echo "Cannot save the timeline because .scratch/cm-timeline.md is a directory." >&2 exit 1 fi mv -f "$timeline_tmp" .scratch/cm-timeline.md && wc -l .scratch/cm-timeline.md ) ``` If the fetch fails, report the error and stop. Proceed to Step 3 only with a timeline saved by this run. Confirm it has the expected structure (preamble, then date headers like `### Mon DD, YYYY`, then numeric observation lines `