/fortune cracks open a fortune cookie: one line of wisdom for your coding session, shown in the transcript and as a toast.

A tiny demo mod for Claude Code. Type /fortune and it cracks open a fortune cookie: one line of coding wisdom, shown in the transcript and as a toast.
/fortune
🥠 It was DNS. It is always DNS.
claude --plugin-dir fortune-cookie
claude plugin validate fortune-cookie claude plugin test fortune-cookie
hooks/register.ts registers the /fortune command at session.start and answers command.run for it. The clock picks the fortune from hooks/fortunes.ts, so the test can pin which one comes out.
hooks/register.ts 26 lines1import type { Register } from 'claude-code'
2
3import { FORTUNES } from './fortunes'
4
5const COMMAND = 'fortune'
6
7export const register: Register = on => {
8 on('session.start', async ($, e, next) => {
9 await $.command.register({
10 name: COMMAND,
11 description: 'Crack open a fortune cookie',
12 })
13
14 return next(e)
15 })
16
17 on('command.run', { command: COMMAND }, async $ => {
18 // The clock picks the fortune, so a test can pin which one comes out.
19 const pick = Math.floor(await $.clock.now()) % FORTUNES.length
20 const text = `🥠 ${FORTUNES[pick] ?? FORTUNES[0]}`
21 $.ui.toast(text)
22
23 return { text }
24 })
25}
26hooks/fortunes.ts 13 lines1export const FORTUNES: readonly [string, ...string[]] = [
2 'A bug you fix today is a page you skip tonight.',
3 'The test you did not write will find you in production.',
4 'Your next commit message will be shorter than you think.',
5 'A rubber duck holds the answer you seek.',
6 'You will soon delete more code than you write. Rejoice.',
7 'The flaky test is not flaky. It is telling you something.',
8 'Good names come to those who rename.',
9 'An off-by-one error is closer than it appears.',
10 'Today is a fine day to read the error message.',
11 'It was DNS. It is always DNS.',
12]
13