Difficulty: Medium | Duration: 30 Minutes | Takeaway: Master the core methods of long-form web novel creation using an AI Agent system
Target Audience
- Developers with 1-5 years of experience interested in AI Agents
- Web novel authors wanting to assist their writing with AI
- Engineers currently building AI writing systems
Core Dependencies and Environment
- Required: Claude Code (Latest Version)
- Language: Python 3.10+
- RAG: Embedding API (ModelScope) + Rerank API (Jina)
- Optional: Node.js 18+ (For Dashboard)
Project Structure Tree
webnovel-writer/
βββ .claude-plugin/
β βββ marketplace.json # Plugin marketplace configuration
βββ agents/ # 8 Agents
β βββ context-agent.md # Creation task brief generation
β βββ data-agent.md # Entity and state management
β βββ consistency-checker.md # Setting consistency validation
β βββ continuity-checker.md # Narrative continuity validation
β βββ high-point-checker.md # Climax/Excitement density check
β βββ ooc-checker.md # Out-of-character (OOC) check
β βββ pacing-checker.md # Pacing ratio check
β βββ reader-pull-checker.md # Retention/Reader-pull check
βββ dashboard/ # Visualization panel
β βββ server.py # Flask backend
β βββ watcher.py # File monitoring
β βββ frontend/ # React frontend
βββ genres/ # Genre templates
β βββ xuanhuan/ # Xuanhuan
β βββ dog-blood-romance/ # Melodramatic romance
β βββ period-drama/ # Ancient Chinese setting
β βββ ...
βββ skills/ # Skill definitions
β βββ init.md # Project initialization
β βββ plan.md # Outline planning
β βββ write.md # Content writing
β βββ review.md # Chapter auditing
β βββ ...
βββ docs/ # Detailed documentation
βββ architecture.md
βββ commands.md
βββ rag-and-config.md
Step-by-Step Guide
Step 1: Install Plugin
Open Claude Code and execute the following commands to install the plugin:
claude plugin marketplace add lingfengQAQ/webnovel-writer --scope user
claude plugin install webnovel-writer@webnovel-writer-marketplace --scope user
TIP
If you only want it to take effect in the current project, change --scope user to --scope project.
Step 2: Install Python Dependencies
python -m pip install -r https://raw.githubusercontent.com/lingfengQAQ/webnovel-writer/HEAD/requirements.txt
This command installs all dependencies for both the core writing pipeline and the Dashboard.
Step 3: Initialize Web Novel Project
In Claude Code, execute:
/webnovel-init
The system will prompt you for a book title, then create a project directory under the current Workspace and write the current project pointer to workspace/.claude/.webnovel-current-project.
Step 4: Configure RAG Environment (Required)
Enter the root directory of the initialized book project and create a .env file:
cp .env.example .env
Edit .env and fill in your API configurations:
# Embedding Model (For vector retrieval)
EMBED_BASE_URL=https://api-inference.modelscope.cn/v1
EMBED_MODEL=Qwen/Qwen3-Embedding-8B
EMBED_API_KEY=your_embed_api_key
# Rerank Model (For result reranking)
RERANK_BASE_URL=https://api.jina.ai/v1
RERANK_MODEL=jina-reranker-v3
RERANK_API_KEY=your_rerank_api_key
WARNING
RAG configuration is mandatory; otherwise, context retrieval will be unavailable, and the AI will experience "amnesia" during writing.
Step 5: Start Creating
You can now begin writing:
# Step 5a: Plan outline
/webnovel-plan 1
# Step 5b: Write Chapter 1
/webnovel-write 1
# Step 5c: Review Chapters 1-5
/webnovel-review 1-5
Execution logic for each command:
| Command | Description |
|---|---|
/webnovel-plan N | Generates an outline for N chapters |
/webnovel-write N | Writes the full text for Chapter N |
/webnovel-review N-M | Audits Chapters N to M |
Step 6: Launch Visualization Dashboard (Optional)
/webnovel-dashboard
Dashboard features:
- Project status overview
- Entity graph visualization
- Chapter/Outline browsing
- Reader-pull metric viewing
TIP
The Dashboard is a read-only panel. Frontend build artifacts are released with the plugin; no local npm build is required.
(Optional) Step 7: Customize Agent Models
All built-in Agents in this project default to inherit (inheriting the current Claude session model). If you wish to specify a model for a specific Agent, edit the frontmatter of the corresponding file:
---
name: context-agent
description: Generate creation task brief
tools: Read, Grep, Bash
model: sonnet # Specify use of the Sonnet model
---
Common options: inherit / sonnet / opus / haiku.
Core Architecture Analysis
Three Laws Against Hallucination
Webnovel Writer solves AI "hallucination" problems fundamentally using these three laws:
| Law | Description | Execution |
|---|---|---|
| Outline is Law | Strictly follow the outline without unauthorized deviation | Context Agent forces loading of chapter outlines |
| Settings are Physics | Adhere to all settings without self-contradiction | Consistency Checker performs real-time validation |
| Invention requires Identification | New entities must be identified and managed | Data Agent automatically extracts and disambiguates |
Dual Agent Architecture
The system adopts a classic "Read-Write Separation" architecture:
Context Agent (Read)
- Builds a "Creation Task Brief" before writing
- Loads chapter context, constraints, and reader-pull strategies
- Ensures the AI knows "what to write" and "what not to write"
Data Agent (Write)
- Extracts entities and state changes from the text
- Automatically updates
state.json,index.db, andvectors.db - Ensures a closed data loop so subsequent chapters "remember" what happened before
Six-Dimensional Parallel Audit
After each chapter is written, 6 Checkers are launched simultaneously:
| Checker | Inspection Focus |
|---|---|
| High-point Checker | Density and quality of exciting/climax points |
| Consistency Checker | Setting consistency (Power levels / Locations / Timeline) |
| Pacing Checker | Strand ratios and gaps (Quest 60% / Fire 20% / Constellation 20%) |
| OOC Checker | Whether character behavior deviates from their profile |
| Continuity Checker | Scene and narrative flow |
| Reader-pull Checker | Hook strength, expectation management, and retention power |
Strand Weave Pacing System
The system features a built-in pacing control mechanism:
- Quest (Main Plot): Ideal ratio 60%, consecutive no more than 5 chapters
- Fire (Romance/Emotional line): Ideal ratio 20%, gap no more than 10 chapters
- Constellation (World-building/Lore): Ideal ratio 20%, gap no more than 15 chapters
Troubleshooting
Q1: Retrieval fails after RAG configuration
Symptom: "no results from RAG" prompt during writing
Troubleshooting:
- Ensure the
.envfile is in the project root directory - Check if the API Key is correct
- Try manually calling the Embedding API to verify connectivity
curl -X POST $EMBED_BASE_URL \
-H "Authorization: Bearer $EMBED_API_KEY" \
-H "Content-Type: application/json" \
-d '{"input": "test text"}'
Q2: Model call timeout during writing
Symptom: /webnovel-write times out after running for a long time
Troubleshooting:
- Check if the network to the API provider is stable
- Try switching to a faster model (e.g., Haiku)
- Increase the timeout parameter in the Agent configuration
Q3: State file corruption
Symptom: state.json or index.db reports "invalid json" or "database locked"
Troubleshooting:
- Backup the current file
- Run the built-in recovery script (see
docs/operations.md) - Manually fix JSON formatting errors
Q4: Dashboard fails to start
Symptom: /webnovel-dashboard is unresponsive or errors out
Troubleshooting:
- Confirm Python dependencies are fully installed
- Check if port 5000 is occupied
- View logs for specific error messages
Q5: Agent model settings not taking effect
Symptom: Modified Agent model configuration but it didn't change
Troubleshooting:
- Confirm the correct Agent file was edited
- Check if YAML format is correct (space after colon)
- Restart the Claude Code session
Q6: Reader-pull check always fails
Symptom: Reader-pull Checker prompts "hooks are not strong enough"
Troubleshooting:
- Check if there is a cliffhanger at the end of the chapter
- See if explicit "plot holes/hooks" are left to be filled
- Check for lack of expectation guidance for the next chapter
Extended Reading / Advanced Directions
1. Custom Genre Templates
The project includes various web novel genre templates (Xuanhuan, Ancient Drama, Melodrama, etc.). You can add your own genre configuration in the genres/ directory.
2. Integration with OpenClaw
Webnovel Writer can be used as a Skill for OpenClaw to achieve a more powerful automated creation workflow.
3. Deep Agent Customization
By modifying the prompts and tools in agents/*.md files, you can make the AI write according to your personal style.
4. Multi-model Hybrid Usage
Try using different models for different tasks: use Opus for the main text, Haiku for audits, and Sonnet for planning.