Skip to main content

Story test

Build PyPI version

CLI tool that runs natural language tests (e.g. "The hero wins in the end") against a markdown text.

Lets you define a list of checks you expect from your story and determines whether each one passes or fails.

It does not replace a human editor, but it's a great tool to aid in the editing phase, for both writers and editors:

  • Make sure your story's main points are addressed while editing your story.
  • Build and grow a repository with standard tests you want to run on manuscripts, and make specific tests for specific genres, etc.

Supports OpenAI, Anthropic, and local Ollama models.

Usage

Create a test file containing assertions about a story:

tests:
	- name: author
		assertion: The story was written by Edgar Allan Poe.
	- name: ending
		assertion: The narrator confesses at the end of the story.

Run the tests against one or more Markdown files:

story-test story.tests.yml story.md
story-test story.tests.yml chapter-1.md chapter-2.md

Failed assertions are reported without failing the process by default. For CI, use strict mode:

story-test story.tests.yml story.md --fail-on-test-failure

The default provider is Ollama. For hosted OpenAI usage, set the API key and select the provider explicitly:

export OPENAI_API_KEY=your-key
story-test story.tests.yml story.md --provider openai --model gpt-4.1-mini

For Anthropic:

export ANTHROPIC_API_KEY=your-key
story-test story.tests.yml story.md \
	--provider anthropic --model claude-opus-5-5

If you are using a Claude Code authorization token, Anthropic's SDK also accepts:

export ANTHROPIC_AUTH_TOKEN=your-token

Ollama remains available as an optional local provider:

STORY_TEST_PROVIDER=ollama sh install.sh
story-test story.tests.yml story.md --provider ollama --model qwen3:8b

🚀 Getting Started

This repo uses direnv, Devbox, Taskfile, and pre-commit for a reproducible dev environment and automatic schema/YAML validation.

Setup

# Automatically enter devbox via direnv (if available)
direnv allow

# Enter dev environment
devbox shell

# Install pre-commit hooks
task pre-commit:install

Tasks

Run task to see a list of available tasks.

Install the development dependencies with:

task environment:dev:install

For a local user installation, run the bootstrap script from this repository:

sh install.sh

This creates an isolated Python environment and installs the story-test command. The installed command can then be used from any directory:

story-test path/to/story.tests.yml path/to/story.md

For an Ollama installation, set STORY_TEST_PROVIDER before running the installer to pull a local model:

STORY_TEST_PROVIDER=ollama STORY_TEST_MODEL=qwen3:30b-a3b sh install.sh

Install Ollama separately only when using the local provider, then download the model through Task:

task environment:ollama:install

To use a model already installed locally:

OLLAMA_MODEL=qwen3:30b-a3b task environment:ollama:install

Run the sample story tests. Failed story assertions are reported but do not fail the task by default:

task test:example-story

The OpenAI and Anthropic providers use their standard OPENAI_API_KEY and ANTHROPIC_API_KEY environment variables. The Ollama provider uses STORY_TEST_MODEL and STORY_TEST_CONTEXT_LENGTH and is the default.

The model can be changed with STORY_TEST_MODEL, and the context window can be changed with STORY_TEST_CONTEXT_LENGTH.

To make failed story assertions fail the task, use the strict variant:

task test:example-story:strict

Run the complete local validation suite:

task test:all

This runs schema validation, Python unit tests, and the sample story tests.

The GitHub Actions workflow validates and builds the package without running an AI provider. Qwen open-weight models are Apache 2.0 licensed and Ollama is MIT licensed; always review the license for the exact model tag you deploy.

Run formatting and pre-commit checks with:

task format:check
task pre-commit:run

Before publishing a release, build and validate both distribution formats:

task package:check

This creates the wheel and source archive under dist/ and validates them with Twine. Increment the version in pyproject.toml before building a new release.

Features

  • JSON structure validation using jq
  • Schema validation using check-jsonschema (temporarily disabled)
  • CI/CD integration with GitHub Actions
  • Versioning schemas with directories like schemas/v1, schemas/v2
  • Documentation with inline schema descriptions
  • Code formatting using prettier or jq
  • Documentation with README or extended docs folder (pending)
  • Schema hosting via $id URLs or SchemaStore (pending)

Metadata

Release files for story-test 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for story-test 2.2.0
File Size Uploaded
story_test-2.2.0.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for story-test 2.2.0
File Interpreter ABI Platform
story_test-2.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.4 kB

Release files / story_test-2.2.0.tar.gz

Download URL story_test-2.2.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b08c6607a72ed4ea43a70e15266a9fc164cca4455298f0bfd85f304bc13e8cb3
BLAKE2b-256 checksum
How to use checksums
81a087cc28dcfa6dd7350ecc32ec16fa443abe9b6b263a68b3d77fdc62dcb7c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / story_test-2.2.0-py3-none-any.whl

Download URL story_test-2.2.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5e01b410b6bb4ce4586c82b7588f5b5b81e33067989c6754e2035ed8ff306e7
BLAKE2b-256 checksum
How to use checksums
b30f25f9dff6cad42a905ff2ea8809d840027f4487c4433e1705effd1092b3ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release history Release notifications | RSS feed

3.0.0

2 release files

2.4.0

2 release files

2.3.1

2 release files

2.3.0

2 release files

This release

2.2.0 This release

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page