Use when
Triggered when the user asks about in-project information such as story settings, characters, power systems, factions, foreshadowing, golden finger, pacing, etc.
Project root protection
export WORKSPACE_ROOT="${CLAUDE_PROJECT_DIR:-$PWD}"
export SCRIPTS_DIR="${CLAUDE_PLUGIN_ROOT}/scripts"
export SKILL_ROOT="${CLAUDE_PLUGIN_ROOT}/skills/webnovel-query"
export PROJECT_ROOT="$(python "${SCRIPTS_DIR}/webnovel.py" --project-root "${WORKSPACE_ROOT}" where)"
PROJECT_ROOTMust include.webnovel/state.json- ForbiddenUnder
${CLAUDE_PLUGIN_ROOT}/read or write project files
Query category → Narrowest tool
First identify the query type, then use the narrowest tool in the table below. Do not load everything by default; only use it for comprehensive / cross-multiple-type queries memory-contract load-context。
| Query type | Keywords | Narrowest tool |
|---|---|---|
| Character historical state | A character at chapter N / state at a point in time / realm changes | knowledge query-entity-state |
| Entity relationships | Relationship / friend or foe / master-disciple / faction affiliation | knowledge query-relationships |
| World rules | Power rules / setting iron laws / realm system constraints | memory-contract query-rules |
| Foreshadowing / open loop | Foreshadowing / urgent foreshadowing / unresolved suspense | memory-contract get-open-loops |
| Comprehensive / complex | Cross-multiple-type, requiring timeline + long-term memory combined | memory-contract load-context |
| Static settings | Character cards / power systems / worldbuilding / factions / tag format | Grep + Read Settings collection |
Reference loading strategy
Load on demand by query type; identify first, then load. Path description:references/ refers to skill-private skills/webnovel-query/references/;../../references/ refers to shared references.
| Query type | Reference | Actual path |
|---|---|---|
| Data flow / priority | Data flow specification | ${SKILL_ROOT}/references/system-data-flow.md |
| Foreshadowing analysis | Foreshadowing analysis | ${SKILL_ROOT}/references/advanced/foreshadowing.md |
| Pacing analysis | Strand mode | ${SKILL_ROOT}/../../references/shared/strand-weave-pattern.md |
| Format query | Tag specification | ${SKILL_ROOT}/references/tag-specification.md |
Do not load more than two references at the same time unless the user's request explicitly spans multiple types.
Query process
-
Identify query type: match keywords against the "Query category → Narrowest tool" table.
-
Locate the pre-writing source of truth by priority(pre-writing source of truth → post-writing source of truth → projection layer):
.story-system/MASTER_SETTING.json- Book-wide main settings (genre, tone, core taboos).story-system/volumes/*.json- Volume-level contract (this volume's goals, pacing strategy).story-system/chapters/*.json- Chapter-level contract (this chapter's focus, dynamic context)- latest accepted
.story-system/commits/chapter_XXX.commit.json- Post-writing facts (finalized state of published chapters) memory-contractseries queries - memory orchestration results (long-term memory, foreshadowing, timeline).webnovel/state.json/index.db- Projection layer (fallback / read-model only, analogous to the "character cards" and "chapter lists" in a web novel backend)
Priority description:
- Pre-writing source of truth (1-3): the "outline, settings, restricted zones" the author must follow before starting to write
- Post-writing source of truth (4): the "finalized state" of published chapters, which cannot be tampered with
- Projection layer (5-6): a "query view" automatically generated from the post-writing source of truth, for quick retrieval
-
Call the narrowest tool for retrieval: call only the required command by type, do not default to loading everything
load-context。
# 角色历史状态:某实体在指定章节时的状态
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${PROJECT_ROOT}" knowledge query-entity-state --entity "{entity_id}" --at-chapter {N}
# 实体关系:某实体在指定章节时的所有关系
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${PROJECT_ROOT}" knowledge query-relationships --entity "{entity_id}" --at-chapter {N}
# 世界规则
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${PROJECT_ROOT}" memory-contract query-rules --chapter {chapter_num}
# 伏笔 / open loop
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${PROJECT_ROOT}" memory-contract get-open-loops
# 仅综合 / 复杂查询:需要时间线 + 长期记忆联合时才用
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${PROJECT_ROOT}" memory-contract load-context --chapter {chapter_num}
For static settings (character cards / power systems / worldbuilding / tag format), directly use Grep to locate the line number, then Read Take the fragment, without going through memory-contract.
- Formatted output: output according to the template below.
Output format
# 查询结果:{关键词}
## 概要
- **匹配类型**: {type}
- **数据源**: {实际命中的真源 / 投影层}
- **匹配数量**: X 条
## 详细信息
{结构化数据,含文件路径和行号}
## 数据一致性检查
{state.json 与静态文件的差异,若无差异则省略}
Boundaries and failure recovery
- Read-only operation, does not modify any project files
- If the data source is missing, clearly inform the user which file is missing
- If the query has no match, return an empty result and suggest checking the scope
- If
.story-system/contract and accepted commit are missing, you must explicitly state that the current query has been downgraded to legacy fallback