Skip to content

AutoFiction-AI/autofiction

Repository files navigation

Autofiction

Autofiction is a research pipeline for long-form AI novel generation and revision. Every job in the pipeline (drafting, reviewing, auditing, revising) is executed by a frontier AI coding agent (Claude Code or Codex), not by vanilla LLM API calls. Each agent receives a prompt and a workspace of files, then autonomously reads, writes, searches, and validates artifacts using its full tool suite. The pipeline decomposes novel writing into staged agentic jobs: premise development, outlining, chapter drafting, chapter review, full-book review, cross-chapter auditing, and revision. The goal is to study how human readers respond to long-form novels generated by frontier AI agents. The pipeline implements one approach to generating such books but does not claim to be the best or only one.

The generated novels are published on autofiction.ai, where all books are clearly labeled as AI-generated. This repository contains the core pipeline code, prompts, schemas, tests, and documentation. The published novel corpus and structured output artifacts live separately in AutoFiction-AI/artifacts. Internal export helpers and one-off rescue utilities have been omitted from this public release so the repository stays focused on the research pipeline itself.

Please read ETHICS.md before using the system.

Team

Autofiction is a research project from the University of Maryland, College Park.

A paper describing this system is in preparation.

How This Was Built

The pipeline code in this repository was written primarily by Codex, with planning and prompt editing done in Claude Code. The novels published on autofiction.ai were generated primarily using GPT-5.4 (xhigh reasoning) and Claude Opus 4.6 (max reasoning). Human involvement was limited to writing premises, iterating on prompts, debugging pipeline failures, and occasionally restarting failed runs. No human edited the novel text itself.

Research Framing

This repository is being released as a research artifact, not as a polished product or turnkey publishing stack. The emphasis is on transparency, reproducibility, and critical inspection of the pipeline's behavior.

A few practical consequences follow from that framing:

  • Runs are expensive and slow. A typical 18-chapter novel with 2 review-revision cycles requires approximately 200 agent jobs and costs roughly $120-250 in API usage depending on the provider and model. All novels published on autofiction.ai were generated using subscription access (ChatGPT Pro and Claude Max, $200/month each) rather than pay-per-token API billing. Even short experiments require substantial wall-clock time.
  • Outputs are not deterministic. Provider behavior, prompt revisions, and orchestration details all affect results.
  • Quality evaluation is subjective. The prompts, review criteria, and recommended settings will keep changing.
  • The codebase documents an evolving research process. Many novels published on this website were generated with earlier versions of the pipeline and thus may not have used all of the stages included in the current version.

What The Pipeline Does

At a high level, a live run follows this shape:

premise -> outline -> parallel chapter drafting -> chapter reviews ->
[full-book review + cross-chapter audit] -> aggregate findings -> revision

The review-and-revision stages can run for multiple cycles. The intent is to catch failure modes that show up repeatedly in AI-generated fiction, including weak causality, repetitive scene construction, cross-chapter redundancy, continuity drift, flat dialogue, and over-regular prose.

The pipeline currently supports two frontier agent runtimes:

  • Claude Code (Anthropic)
  • Codex (OpenAI)

This is a deliberate architectural choice. Each pipeline stage needs to read prior artifacts, write structured outputs, run validation, and use tools like grep, file search, and shell commands. These capabilities require agentic execution, not simple prompt-in/text-out API calls. The cross-chapter audit, for example, uses grep to count prose patterns and verify consistency across the full manuscript rather than estimating from memory.

Recommended Provider Configuration

The most recent novels on autofiction.ai (The Wrong Mouth, Involuntary Architecture) used the following configuration:

Stage Provider Model Reasoning
Premise Manual (user-written)
Outline Claude Code Claude Opus 4.6 max
Chapter drafting Claude Code Claude Opus 4.6 max
Chapter review Codex GPT-5.4 xhigh
Full-book review Claude Code Claude Opus 4.6 max
Cross-chapter audit Claude Code Claude Opus 4.6 max
Revision (structural, prose) Codex GPT-5.4 xhigh
Revision (dialogue pass) Claude Code Claude Opus 4.6 max

The general pattern: Claude for creative generation (outline, drafting, dialogue revision) and for global review (full-book review, cross-chapter audit), where in testing it identified more legitimate issues than Codex. Codex for chapter-level review and revision. The dialogue revision pass is overridden separately because dialogue voice benefits from the same model that drafted the original text. These are not hard requirements. The pipeline is provider-flexible and any combination of supported runtimes can be used per stage.

Repository Contents

This repository contains only the pipeline code, not generated novels or run artifacts. The complete run directories for every published novel (including intermediate drafts, review outputs, revision reports, and job logs) are in the companion repository: AutoFiction-AI/artifacts.

Key paths:

  • run_novel.sh: main shell entrypoint
  • scripts/runner.py: primary orchestrator
  • scripts/posthoc_revision.py: posthoc review/revision pipeline for existing manuscripts
  • prompts/: stage prompts and audit/review instructions
  • schemas/: JSON schemas used to validate stage artifacts
  • tests/: unit and regression coverage for orchestration logic
  • docs/: supplementary documentation, including stage contracts
  • .github/workflows/: smoke and CI automation

Local run output is typically written under runs/, which is gitignored in this code repository.

Artifacts And Provenance

If you want to inspect generated novels, review artifacts, or posthoc revision bundles (structured records of editorial passes applied after initial generation), use the companion artifacts repository:

That repository contains:

  • exported manuscripts
  • planning artifacts
  • review outputs
  • revision reports
  • selected posthoc editorial provenance (review and revision artifacts from additional editing passes on finished novels)

The split between code and artifacts is intentional. It keeps this repository focused on the pipeline itself while preserving public evidence about how the released novels were generated and revised.

Running The Pipeline

The pipeline requires:

  • Python 3.11+
  • a working Codex CLI and/or Claude Code CLI

Subscription tier note: This code has only been tested with ChatGPT Pro ($200/month) and Claude Max ($200/month) subscriptions. Lower-tier subscriptions will likely hit rate limits, particularly the 5-hour usage caps on both platforms. Running the full pipeline on a lower tier may require adding sleep intervals between jobs or restarting runs after rate-limit cooldowns, neither of which is currently built into the pipeline.

Before running live jobs:

  1. Install and authenticate the provider CLI you want to use.
  2. Verify the command works in your shell.
  3. Set CODEX_BIN or CLAUDE_BIN if the binary is not on your PATH.

Live runs are unattended agent executions. In the current implementation, Codex jobs run in workspace-write mode and Claude jobs are launched with noninteractive permission-skipping flags so the pipeline can complete without human confirmation prompts. Review the prompts, runner behavior, and working-directory boundaries before pointing the system at any sensitive files or directories.

For the full CLI surface:

./run_novel.sh --help

For a minimal local smoke test without provider calls:

./run_novel.sh \
  --generate-premise \
  --run-dir ./runs/dry_run_check \
  --max-cycles 1 \
  --min-cycles 1 \
  --dry-run

Disclosure And Responsible Use

The code in this repository is licensed under Apache 2.0, but that legal permission does not exhaust the project's ethical expectations.

In particular:

  • We believe novels generated wholly or substantially with this pipeline should be clearly disclosed as AI-generated when they are distributed publicly.
  • We reject undisclosed AI publishing and deceptive claims of solely human authorship for machine-generated texts.
  • We strongly encourage retaining and publishing provenance evidence when sharing outputs derived from this pipeline.

Those norms are described in more detail in ETHICS.md.

Citation

To cite the pipeline code:

@software{pham_chang_iyyer_2026_pipeline,
  author  = {Pham, Chau Minh and Chang, Yapei and Iyyer, Mohit},
  title   = {AutoFiction Pipeline},
  year    = {2026},
  url     = {https://github.com/AutoFiction-AI/autofiction},
  note    = {Research pipeline for long-form AI novel generation}
}

To cite the reading platform and published novels:

@software{pham_chang_iyyer_2026,
  author  = {Pham, Chau Minh and Chang, Yapei and Iyyer, Mohit},
  title   = {AutoFiction},
  year    = {2026},
  version = {0.1.0},
  url     = {https://www.autofiction.ai/},
  note    = {Web platform}
}

License

The software in this repository is licensed under Apache License 2.0.

That license applies to the code in this repository. It does not by itself grant rights to separately licensed books or artifact corpora published elsewhere.

About

agentic pipeline to generate novels published on autofiction.ai

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors