Init

From Chanw-research/claude-code-paper-writing · View interactive version

Init is an AI agent skill from the GitHub repository Chanw-research/claude-code-paper-writing. Bootstrap ΩmegaWiki from user sources plus optional discovery, then ingest the final paper set in parallel

How to use this skill

Skill file

/init

Build a wiki from raw/ with deterministic source preparation, planner-guided discovery, provisional notes/web scaffolding, and parallel /ingest fan-out/fan-in.

Use these local references on demand:

Inputs

Outputs

Wiki Interaction

Reads

Writes

Graph edges created

Workflow

Pre-condition: working directory is the project root containing wiki/, raw/, and tools/. Set WIKI_ROOT=wiki/. Resolve PYTHON_BIN once and reuse it for every Python command during /init so the workflow stays on the interpreter that setup.sh prepared:

# Find the project root via git so worktree subagents can still locate .venv.
# .venv is gitignored, so a subagent whose cwd is ../.worktrees/<branch>/
# doesn't have one — without this lookup it falls back to system python3 and
# misses the .env-loaded API keys plus the installed deps (deepxiv-sdk etc.).
# git rev-parse --git-common-dir returns the main repo's .git regardless of
# which worktree the shell is in; its parent is the project root.
GIT_COMMON_DIR=$(git rev-parse --git-common-dir 2>/dev/null || true)
PROJECT_ROOT=""
if [ -n "$GIT_COMMON_DIR" ]; then
  PROJECT_ROOT=$(cd "$(dirname "$GIT_COMMON_DIR")" 2>/dev/null && pwd)
fi

if   [ -x "$PROJECT_ROOT/.venv/bin/python" ];         then PYTHON_BIN="$PROJECT_ROOT/.venv/bin/python"
elif [ -x "$PROJECT_ROOT/.venv/Scripts/python.exe" ]; then PYTHON_BIN="$PROJECT_ROOT/.venv/Scripts/python.exe"
elif [ -x .venv/bin/python ];                         then PYTHON_BIN=.venv/bin/python
elif [ -x .venv/Scripts/python.exe ];                 then PYTHON_BIN=.venv/Scripts/python.exe
else                                                       PYTHON_BIN=python3
fi
export PYTHON_BIN

Step 1: Initialize wiki structure

"$PYTHON_BIN" tools/research_wiki.py init wiki/

Create the standard wiki directories, graph/, outputs/, index.md, and log.md. Do not add a second init log entry here.

Step 2: Prepare local inputs into `raw/tmp/`

"$PYTHON_BIN" tools/init_discovery.py prepare --raw-root raw --pdf-titles-json .checkpoints/init-pdf-titles.json --output-manifest .checkpoints/init-prepare.json

Step 3: Plan discovery, trim the final set, and write the source manifest

"$PYTHON_BIN" tools/init_discovery.py plan [--topic "<topic>"] --mode auto --raw-root raw --wiki-root wiki --prepared-manifest .checkpoints/init-prepare.json --allow-introduction <true|false> --output-plan .checkpoints/init-plan.json

Then run:

"$PYTHON_BIN" tools/init_discovery.py fetch --raw-root raw --plan-json .checkpoints/init-plan.json --prepared-manifest .checkpoints/init-prepare.json --output-sources .checkpoints/init-sources.json --id <candidate-id> --id <candidate-id>

Step 4: Create scaffold pages before paper ingest

Create one wiki/Summary/{area}.md, the needed wiki/topics/{slug}.md, and provisional ideas/, concepts/, and claims/ from notes/web when warranted.

Rules:

Provisional note: seeded from raw/notes or raw/web during /init; pending validation from ingested papers.

Step 5: Parallel paper ingest with worktree isolation

Paper sources for this step come strictly from .checkpoints/init-sources.json:

Parallel ingest contract:

Step 6: Fan-in, rebuild, and final report

After all subagents complete:

"$PYTHON_BIN" tools/research_wiki.py dedup-edges wiki/
"$PYTHON_BIN" tools/research_wiki.py dedup-citations wiki/
"$PYTHON_BIN" tools/research_wiki.py rebuild-index wiki/
"$PYTHON_BIN" tools/research_wiki.py rebuild-context-brief wiki/
"$PYTHON_BIN" tools/research_wiki.py rebuild-open-questions wiki/
"$PYTHON_BIN" tools/lint.py --wiki-dir wiki/ --fix

Report separately:

If stash_ref exists, pop it at the end. If stash pop fails, keep the checkpoint and report the failure.

Constraints

Error Handling

Dependencies

Tools (via Bash)

Skills

External APIs used by `init_discovery.py`

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.