Writing a 2-million-word web novel with AI sounds impossible β Claudeβs context window tops out at a fraction of that, and across hundreds of chapters the AI inevitably forgets character details, contradicts earlier plot, or hallucinates facts. WebNovel Writer solves this with an architecture worth studying even if you never write fiction: RAG-enhanced context retrieval, entity graph tracking, and narrative momentum metrics. The same patterns apply to any long-context AI application.
Source: lingfengQAQ/webnovel-writer GitHub. Discovery note: @δ»ε€©ε¦ηΉε₯? on Douyin.
Why This Matters Beyond Novels
If you care about long-context AI applications β research writing, legal document drafting, code bases that span months β this toolβs architecture solves problems youβll face too:
| Problem | How Most Tools Fail | How WebNovel Writer Solves It |
|---|---|---|
| Forgetting (context window overflow) | Conversation history truncated, key facts lost | RAG retrieval of relevant past content per task |
| Character drift | Names, traits, relationships mutate across chapters | Entity graph with explicit character profiles |
| Plot contradictions | AI invents conflicting details | Structured metadata (outlines, plot threads) |
| Narrative deadness | AI-generated text feels flat | βReading momentumβ metrics (hooks, cool-points, narrative debt) |
The Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β WebNovel Writer Workflow β
β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β β PLAN ββββββΆβ WRITE ββββββΆβ REVIEW β β
β β β β β β β β
β β/webnovel-β β/webnovel-β β/webnovel-β β
β β plan 1 β β write 1 β β review β β
β β β β β β 1-5 β β
β ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ β
β β β β β
β βΌ βΌ βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββ β
β β Persistent Story Layer β β
β β β β
β β ββββββββββββββ ββββββββββββ βββββββββββ β
β β β Entity β β Chapter β β Plot ββ β
β β β Graph β β Summaries β β Threadsββ β
β β β(characters,β β(searchableβ β(active β β
β β β settings, β β via RAG) β β arcs) ββ β
β β β relations) β β β β ββ β
β β ββββββββββββββ ββββββββββββ βββββββββββ β
β β β β
β β ββββββββββββββββββββββββββββββββββββββ β β
β β β Embeddings + Reranking (Qwen+Jina) β β β
β β ββββββββββββββββββββββββββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Three-Stage Workflow
- Plan β Outline structure, define characters, set plot threads
- Write β For each chapter, retrieve relevant context via RAG, generate with entity graph constraints
- Review β Check consistency, track momentum metrics, flag contradictions
Key Technical Insights
RAG-over-chapters instead of giant context Donβt try to stuff the whole novel into the prompt. For each new chapter, semantic search retrieves:
- Previous chapters relevant to the current scene
- Character profiles for people appearing in this chapter
- Active plot threads that need progression
- Any βnarrative debtβ that should be paid off
Entity graph as source of truth Characters have structured profiles: name, physical description, backstory, relationships, current state. Claude writes against this graph, not against fuzzy recollection. When the graph says βAlice is afraid of water,β Alice stays afraid of water in chapter 200.
Reading momentum as a metric The review agent tracks narrative momentum:
- Hooks: cliffhangers, unresolved tension
- Cool-points: memorable scenes, character moments
- Narrative debt: promises made that havenβt been delivered
This is essentially a quality metric for fiction β something that usually requires human editors.
Installation
# Via Claude Code marketplace
/plugin marketplace add lingfengQAQ/webnovel-writer
/plugin install webnovel-writer
# Install Python dependencies
pip install -r requirements.txt
# Initialize project
/webnovel-init "My Novel Name"
# Configure embeddings (example: Qwen + Jina)
# Edit config.yaml with your API keys
# Start writing
/webnovel-plan 1 # Plan chapter 1
/webnovel-write 1 # Write it
/webnovel-review 1-5 # Review chapters 1-5
Optional: /webnovel-dashboard launches a read-only visual dashboard showing project state, entity relationships, and chapter progression.
Model Flexibility
Different agents can use different Claude models based on task complexity:
| Task | Recommended Model |
|---|---|
| Quick drafts | Haiku (fast, cheap) |
| Main writing | Sonnet (balanced) |
| Complex plot resolution | Opus (deep reasoning) |
| Consistency review | Sonnet |
This is a harness pattern β match intelligence to stage β same principle as the planning/execution/verification phases in coding agents.
What This Teaches About Long-Context AI
Even if you never write fiction, the patterns here apply to any long-running AI project:
- Donβt fight the context window β bypass it with RAG β Retrieve only whatβs relevant, not everything
- Structured metadata beats unstructured memory β Entity graphs, plot threads, and typed profiles are more reliable than βremember what we talked aboutβ
- Separate concerns across phases β Plan/write/review instead of one giant prompt
- Define quality metrics, not just correctness β βIs this chapter engaging?β is the fiction equivalent of βis this code maintainable?β β measure it explicitly
- Match model to task β Opus for the hard parts, Haiku for the easy parts
These are the same principles behind harness engineering and Karpathyβs LLM Knowledge Bases. The web novel is just a concrete application of the general pattern.
How LearnAI Team Could Use This
- Long-context curriculum β use the project as a concrete example of RAG, entity graphs, and structured memory for multi-session AI work.
- Agent workflow demos β teach plan/write/review loops as a reusable pattern for research, documentation, and coding agents.
- Creative AI labs β let students compare naive long-form generation against retrieval-backed, metadata-constrained generation.
- Quality evaluation practice β adapt the momentum and consistency checks into rubrics for evaluating AI-generated artifacts.
Real-World Use Cases
- Long-form fiction production β maintain continuity across hundreds of chapters and millions of words.
- Research report drafting β retrieve relevant prior notes while preserving entity, claim, and citation consistency.
- Legal or policy drafting β track obligations, actors, definitions, and contradictions across large document sets.
- Game or worldbuilding bibles β keep characters, locations, factions, timelines, and unresolved plot threads consistent.
Links
- GitHub: lingfengQAQ/webnovel-writer
- Current version: check the GitHub README / releases before installing; command names and plugin packaging can change.