From paper-deepstudy
Use when the user wants to regenerate title candidates for an existing xhs.md or wechat.md rendering and pick a new one. Re-dispatches title-generator with optional --style filter, lets the user choose, swaps the title into the rendering, archives the prior title.
npx claudepluginhub chansigit/studypaper --plugin paper-deepstudyThis skill is limited to using the following tools:
Invoke after `/paper:study` has produced the notes set. Each invocation regenerates titles for one platform and applies the user's choice.
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Generates original PNG/PDF visual art via design philosophy manifestos for posters, graphics, and static designs on user request.
Invoke after /paper:study has produced the notes set. Each invocation regenerates titles for one platform and applies the user's choice.
Required first arg: xhs or wechat.
Optional flags:
--style <hook|literal|question|numbers|contrast>: bias the generator toward one style. Without this, the generator produces one of each style (5 candidates total).--paper <slug>: target a specific paper folder.Parse first positional arg as PLATFORM (must be xhs or wechat). If invalid, abort with usage hint.
Resolve target paper folder
Source the shared helper and resolve which paper folder this invocation targets:
source $CLAUDE_PLUGIN_ROOT/scripts/lib/resolve-paper.sh
resolve_paper "$@"
# After: $PAPER_DIR, $PAPER_SLUG, $PAPER_AUTODETECTED are set.
# If $PAPER_AUTODETECTED is "true", the helper already printed a warning to stderr.
If resolve_paper returns non-zero, abort with the helper's stderr message. Verify notes/source.md, notes/titles.md, and notes/<platform>.md all exist; abort with helpful message otherwise.
Capture --style <value> if present as STYLE_FILTER; validate it's one of the 5 allowed values.
Set:
SOURCE_PATH=$PAPER_DIR/notes/source.mdTITLES_PATH=$PAPER_DIR/notes/titles.mdRENDERING_PATH=$PAPER_DIR/notes/<platform>.mdPLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT}Source the log-dispatch helper and extract plugin version:
source $CLAUDE_PLUGIN_ROOT/scripts/lib/log-dispatch.sh
PLUGIN_VERSION=$(grep -m1 '"version"' $CLAUDE_PLUGIN_ROOT/.claude-plugin/plugin.json | sed -E 's/.*"version"[^"]*"([^"]+)".*/\1/')
Read the YAML frontmatter of $RENDERING_PATH to extract its current title: value as OLD_TITLE.
titles.mdTITLES_BAK_NN=1
while [ -e "$TITLES_PATH.bak.$TITLES_BAK_NN" ]; do
TITLES_BAK_NN=$((TITLES_BAK_NN + 1))
done
TITLES_BAK_PATH="$TITLES_PATH.bak.$TITLES_BAK_NN"
cp "$TITLES_PATH" "$TITLES_BAK_PATH"
Read $PLUGIN_ROOT/prompts/title-generator.md. Dispatch:
Agent(
description: "title-generator (retitle for <platform>)",
subagent_type: "general-purpose",
prompt: <contents of title-generator.md> + concrete inputs:
SOURCE_PATH=$SOURCE_PATH
OUTPUT_PATH=$TITLES_PATH
TEMPLATE_PATH=$PLUGIN_ROOT/templates/notes/titles.md
STYLE_FILTER=<STYLE_FILTER if set, else omit>
PLUGIN_VERSION=$PLUGIN_VERSION
)
Wait for completion. Log the dispatch:
log_dispatch title-generator notes/titles.md ok
If the generator failed: log_dispatch title-generator notes/titles.md failed
The generator writes a fresh titles.md with new candidates in ## xhs and ## wechat sections.
Important: the generator overwrites titles.md for both platforms. The other platform's section also gets refreshed. This is intentional — calling retitle bumps both lists, but only the targeted platform's rendering is updated. To preserve the other platform's title selection, the orchestrator extracts and re-applies it after Stage 4 (see Stage 4.2).
Parse the new titles.md's ## <platform> group. Show the user (in their invocation language):
New title candidates for <platform>:
1. <candidate 1> — <style>
2. <candidate 2> — <style>
3. <candidate 3> — <style>
4. <candidate 4> — <style>
5. <candidate 5> — <style>
Current title: "<OLD_TITLE>"
Which one? (number 1-5, or 'keep' to abort and revert titles.md, or 'regen' to re-run with a different style filter)
Important: $TITLES_BAK_PATH (set in Stage 2.1) is the SINGLE original-state backup taken on first entry to this stage. Even if the user re-runs Stage 2.2 multiple times via regen, this restore point does NOT change — keep always restores the pre-retitle state. Stage 2.1 must NOT be re-executed during the regen loop. The regen branch loops back to Stage 2.2 (NOT Stage 2.1), so the original backup persists.
Wait for user input. Parse:
NEW_TITLE = candidates[<num> - 1]. Proceed to Stage 3.keep → restore titles.md from $TITLES_BAK_PATH, exit gracefully.regen → re-prompt for style, then re-dispatch title-generator (loop back to Stage 2.2). Cap at 3 regens to avoid runaway.RENDERING_BAK_NN=1
while [ -e "$RENDERING_PATH.bak.$RENDERING_BAK_NN" ]; do
RENDERING_BAK_NN=$((RENDERING_BAK_NN + 1))
done
RENDERING_BAK_PATH="$RENDERING_PATH.bak.$RENDERING_BAK_NN"
cp "$RENDERING_PATH" "$RENDERING_BAK_PATH"
Use the Edit tool to replace the YAML frontmatter title: line in $RENDERING_PATH. The YAML frontmatter looks like:
---
title: <OLD_TITLE>
length_target: ...
length_max: ...
figures:
...
---
Replace title: <OLD_TITLE> with title: <NEW_TITLE>. Also replace any first-line H1 # <OLD_TITLE> after the frontmatter (if it matches OLD_TITLE exactly; otherwise leave the H1 alone).
Read $TITLES_PATH. Find the ## history section (the titles template seeds an empty placeholder). Append:
- <OLD_TITLE> — replaced for <platform> on <iso8601-utc>
Use the Edit tool. If ## history section is missing (shouldn't happen; the template includes it), append it at end of file.
The other platform (the one not being retitled) had its ## <other-platform> group overwritten in Stage 2.2. Read $TITLES_BAK_PATH (Stage 2.1's backup) and extract the prior ## <other-platform> group. Replace the new file's ## <other-platform> group with the saved one using the Edit tool.
This guarantees:
✓ Retitled notes/<platform>.md
New title: "<NEW_TITLE>"
Old title archived in titles.md ## history
Backups:
titles.md.bak.<TITLES_BAK_NN>
<platform>.md.bak.<RENDERING_BAK_NN>
--regen loop is capped at 3 to prevent runaway./paper:refine-notes.