---
title: "storytime"
url: "https://claudemods.dev/zh-cn/builds/storytime-f81e91"
source: "https://github.com/maddiedreese/cc-storytime"
source_type: "github"
repo: "https://github.com/maddiedreese/cc-storytime"
author: "maddiedreese"
author_handle: "maddiedreese"
stars: 8
category: "仪表盘与 HUD"
categories: ["hud"]
tags: ["above-prompt-ui", "function-hooks", "hooks", "local-transformer", "tinystories"]
permission_level: 2
scan_complete: true
install: "claude plugin marketplace add maddiedreese/cc-storytime\nclaude plugin install storytime@cc-storytime"
added: "2026-11-13T05:02:44.369Z"
updated: "2026-09-15T01:38:25Z"
locale: "zh-cn"
content_locale: "zh-cn"
---

# storytime

一个 260K 参数的 TinyStories transformer，作为模组运行在 Claude Code 内，在当前工具、文件和提示词词语所播种的提示符上方写出一段简短的本地故事。

## Description

Storytime 是一个基于函数钩子的 Claude Code 模组，会在提示符上方渲染一个三行带状区域。一个 260K 参数的 TinyStories transformer（Karpathy 的 stories260K，dim 64，5 层，8 个注意力头，词表 512）被移植为基于类型化数组的纯 TypeScript，完全在本地运行，零 API token，并被限速以呈现出打字般的效果。它在每次提示词和工具调用时重新播种（最多每十二秒一次）：Edit 映射为铅笔，Write 映射为钢笔，Read 映射为书，Bash 映射为机器人，被触碰的文件名会成为主角名字。命令包括 /story、/story <name> 和 /story off|on。安装需要 CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1，以及 /plugin marketplace add maddiedreese/cc-storytime 和 /plugin install storytime@cc-storytime。权重以 int8 行量化并作为 base64 嵌入；MIT 许可。

## Install

```
claude plugin marketplace add maddiedreese/cc-storytime
claude plugin install storytime@cc-storytime
```

## Original README

# Storytime

A 260K-parameter transformer running inside Claude Code as a mod. It sits
above the prompt and writes a short story about whatever Claude is working
on: the tool Claude just called picks the kind of hero, the file it touched
names the hero, and a word from your prompt is what the hero finds. Every
token is generated locally by the mod's own TypeScript; nothing goes to the
API.

```
Storytime · TinyStories-260K · local transformer · 0 API tokens
Once upon a time, there was a little pencil named Auth. Auth loved to draw
pictures of the sun and the moon. One day, Auth saw a big tree…▍
seeded by Edit auth-service.ts · 4300 tok/s · /story
```

The model is Andrej Karpathy's `stories260K` from `karpathy/tinyllamas`
(dim 64, 5 layers, 8 heads, 4 KV heads, vocab 512), the same checkpoint
[gbc-transformer](https://github.com/maddiedreese/gbc-transformer) runs on
a Game Boy Color at one token every 2 minutes 49 seconds. Here it runs at a
few thousand tokens a second and is throttled to two tokens per 80 ms so it
reads as typing.

## Install

Mods are built on function hooks, which are early access in Claude Code
2.1.272 and later, so start Claude Code with the flag:

```sh
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude
```

Then, inside Claude Code, add this repository as a marketplace and install
the plugin:

```
/plugin marketplace add maddiedreese/cc-storytime
/plugin install storytime@cc-storytime
```

Or run it from a clone without installing:

```sh
git clone https://github.com/maddiedreese/cc-storytime
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude --plugin-dir ./cc-storytime
```

## Use

Work as usual. The band reseeds on each prompt you send and on tool calls,
at most once every twelve seconds.

- `/story` writes a new story.
- `/story <name>` writes one about that hero.
- `/story off` hides the band (remembered across sessions); `/story on` brings it back.

Heroes by tool: Edit is a pencil, Write a pen, Read a book, Bash a robot,
Grep a dog, Glob a bird, WebFetch a fish, Agent a bear, your own prompt a
girl. A file named `auth-service.ts` makes a hero named Auth; `git status`
makes one named Git. Developer words in your prompt become story things: a
bug stays a bug, a test is a puzzle, a branch is a tree, a deploy is a boat.

## How it is built

| file | what it is |
| --- | --- |
| `hooks/register.ts` | The hooks module: `session.start` binds `$` and registers `/story`; `turn.start` and `tool.call` reseed; `ui.render` of `AbovePrompt` draws the band over whatever is beneath it; a `$.clock.every` ticks generation. |
| `hooks/model.ts` | The transformer: RMSNorm, RoPE, grouped-query attention with a KV cache, SwiGLU, tied embeddings. Float32 typed arrays; a port of `run.c`. |
| `hooks/tokenizer.ts` | The llama2.c BPE tokenizer with byte fallback. |
| `hooks/story.ts` | One story: prefill, then a token per step, stopping on EOS or a sentence end. |
| `hooks/seed.ts` | Activity to opening line. |
| `hooks/views.tsx` | The band's three rows. |
| `hooks/weights.ts` | Generated: the int8 row-quantized weights (276 KB) and the tokenizer, base64, since a hooks module has no file access of its own for binaries. |
| `tools/pack.py` | Writes `weights.ts` from `stories260K.bin` and `tok512.bin`. |
| `tools/verify.ts` | `node tools/verify.ts`: checks the port's greedy output against the C reference and times it. |

The hooks environment has no Node and no DOM, only web globals, so the whole
runtime is plain ES2023 on typed arrays. Nothing here uses WebAssembly.

### Regenerating the weights

```sh
curl -LO https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/stories260K.bin
curl -LO https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/tok512.bin
python3 tools/pack.py stories260K.bin tok512.bin hooks/weights.ts
```

## Tests

```sh
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude plugin test .
```

`tsc -p tsconfig.json` typechecks against `.claude/types/claude-code.d.ts`,
which `/plugin-types` writes inside a session with function hooks enabled.

## Credits

- TinyStories-260K and its tokenizer: Andrej Karpathy, `karpathy/tinyllamas`.
- The idea of drawing above the prompt with function hooks: sezaakgun's cc-arcade.

## License

MIT
