One sentence: what the mod does and how you use it.

One sentence: what the mod does and how you use it.
Requires Claude Code 2.1.287 or later.
claude plugin marketplace add vynnlee/mods
claude plugin install my-mod@vynnlee
| To | Do |
|---|---|
| Say hello | /my-mod |
/plugin configure my-mod@vynnlee
| Setting | Default | Values |
|---|---|---|
language | en | en, ko (Korean) |
| Hooks | session.start, command.run (my-mod) |
| Calls | $.command.register, $.state.get, $.state.set |
No network requests, no processes, no files.
hooks/register.tsx 22 lines1// my-mod: replace this with what the mod does and how it is used.
2import { atom, update } from 'claude-code'
3import type { Register } from 'claude-code'
4import { text, type Lang } from './text'
5
6const runs = atom({ plugin: 'my-mod', key: 'runs' } as const, 0)
7
8export const register: Register = (on, options) => {
9 const lang: Lang = options.language === 'ko' ? 'ko' : 'en'
10 const t = text[lang]
11
12 on('session.start', async ($, e, next) => {
13 await $.command.register({ name: 'my-mod', description: t.cmd })
14 return next(e)
15 })
16
17 on('command.run', { command: 'my-mod' }, async ($) => {
18 const n = await update($, runs, v => v + 1)
19 return { text: t.hello(n) }
20 })
21}
22hooks/text.ts 14 lines1// The pure part of the mod: logic and every message in both languages. Tested in text.test.ts.
2export type Lang = 'en' | 'ko'
3
4export const text = {
5 en: {
6 cmd: 'Say hello',
7 hello: (n: number) => `Hello. This session has run /my-mod ${n} times.`,
8 },
9 ko: {
10 cmd: '인사하기',
11 hello: (n: number) => `안녕하세요. 이 세션에서 /my-mod 를 ${n}번 실행했습니다.`,
12 },
13} satisfies Record<Lang, Record<string, unknown>>
14types/index.d.ts 8 lines1export type Runs = number
2
3declare module 'claude-code' {
4 interface PluginState {
5 'my-mod': { runs: Runs }
6 }
7}
8