Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Borrowed Hour

License: MIT Runs in Claude Artifacts Opening: Sonnet 4.6 Continuation: Haiku 4.5 PRs welcome Forks encouraged GitHub stars

A literary, mood-driven interactive text adventure that runs as a Claude Artifact inside the Claude.ai chat. Five premises — Echo, Neon, Omen, Dream, and a Wild custom-scenario builder — each a contained "hour" with its own voice and its own ways to win or lose. The aesthetic is twilight-and-cream serif, typewriter reveal, and narrative-flavored loading phrases: the wait is part of the texture.

How to run it

The whole engine is one self-contained React file — the-borrowed-hour.jsx.

  1. Open claude.ai and start a new chat.
  2. Ask Claude to create an Artifact, or open the Artifacts panel.
  3. Paste the entire contents of the-borrowed-hour.jsx as the Artifact source.
  4. Run it, and pick an hour.

It only runs inside Claude Artifacts. The engine calls https://api.anthropic.com/v1/messages directly and relies on the Artifacts sandbox to proxy and authenticate that request. There is no API key in the code, and you should not add one — outside the sandbox the fetch will simply fail.

The five realms

Realm Title The hook
ECHO The 8:11 A commuter train, a Tuesday morning, and a folded note in your own handwriting you don't remember writing.
NEON The Vermillion Thread Twenty minutes in an elevator going somewhere you've never been allowed. The Thread is deciding what to do with you.
OMEN Three Nights to the Solstice You saw the queen die. You cannot tell anyone. Three nights remain, and the assassin already moves among us.
DREAM The Carnival Lethe A circus that performs in the dreams of sleepers. Tonight the dreamer is dying, the ringmaster is missing, and the big top has begun to leak.
WILD The Unwritten Hour Your premise. Write a seed and the engine builds the hour around it.

Full write-ups in docs/PREMISES.md.

How it works

  • Two-tier model strategy. Sonnet 4.6 writes the opening scene only — the longest, voice-setting piece of prose. Haiku 4.5 carries every subsequent turn and the post-game discussion, for roughly 30–40% the cost of all-Sonnet.
  • Forced structured output. Every in-fiction turn is a forced narrate_and_update_state tool call, so narration and game state are always produced in lockstep — no fragile JSON-in-prose parsing.
  • Private GM scratchpad. The model gets a hidden working space that runs an explicit boundary check and style check before every turn.
  • Public/hidden state boundary. Player-facing state is "the player's diary" — only what they've actually been shown. Clocks, twists, and secret motives live in hidden GM state.
  • 1-hour prompt caching. The system prompt and tool schema are cached with an explicit ttl: "1h", matching the human pacing of interactive fiction.

Full internals in docs/ARCHITECTURE.md.

Make it yours

Forking is the point. The engine is built to be taken apart:

  • Switch models — run it all on Opus, all on Haiku, or any mix.
  • Rewrite the premises — replace the five realms with your own worlds.
  • Add RPG mechanics — HP, stats, dice rolls, inventory weight, factions.
  • Reskin it — the entire look is one CSS template literal.
  • Change the voice — retune the authorial register in the system prompt.

The hands-on guide is docs/ADAPTING.md, and CONTRIBUTING.md covers contributing back.

License

MIT © 2026 faded-penguin021

About

A literary interactive fiction engine using Claude. Sonnet 4.6 writes the opening; Haiku 4.5 continues. Forced tool calls with private scratchpad for state & leakage prevention. MIT licensed.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages