modscode / 図鑑 / lesson-learner
lesson-learner
Claude gets better at your project without you writing rules: your corrections and the command errors Claude fixes become one-press lessons for CLAUDE.md.
何をするか
- プロンプトの上の帯・欄・トーストを描く
- /lessons を足す
- ツールの呼び出しを見張る
- prompt.submit・session.compact・session.end・session.start ほか 2 個にフックする
- ターンをまたいで自分の状態を持つ
良いところ
- ネットワークに出ない
- プロセスを起こさない
- TypeScript で書かれている
- デスクトップ専用の分岐がある
作り始めるためのコード
2 種類あります。上のデザインから modscode が書いた雛形と、その Mod 自身のコードのうち描いている部分です。
雛形(register.tsx)
import type { Register } from 'claude-code'
// Drawn like lesson-learner by mako-code (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/mako-code-lesson-learner/
// Written by modscode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
// the band above the prompt; what else goes there is drawn under it
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const { Box, Text, Button } = $.ui.resolve(e)
const mark = '…'
const label = '…'
const mark2 = '…'
const mark3 = '…'
return (
<Box flexDirection="column">
<Box flexDirection="column">
<Box flexDirection="row" columnGap={1}>
<Text bold>
{mark}
</Text>
<Box flexShrink={1} flexGrow={1}>
<Text wrap="wrap" />
</Box>
</Box>
<Box flexDirection="row" flexWrap="wrap" columnGap={1} paddingLeft={2}>
<Button label={`${label}`} />
<Button label={`${label}`} />
<Button label={`${label}`} />
</Box>
</Box>
<Box flexDirection="column">
<Box flexDirection="row" columnGap={1}>
<Text bold>
{mark2}
</Text>
<Box flexShrink={1} flexGrow={1}>
<Text wrap="wrap" />
</Box>
</Box>
<Box flexDirection="row" flexWrap="wrap" columnGap={1} paddingLeft={2}>
<Button label={`${label}`} />
<Button label={`${label}`} />
<Button label={`${label}`} />
</Box>
</Box>
<Box flexDirection="column">
<Box flexDirection="row" columnGap={1}>
<Text bold>
{mark3}
</Text>
<Box flexShrink={1} flexGrow={1}>
<Text wrap="wrap" />
</Box>
</Box>
<Box flexDirection="row" flexWrap="wrap" columnGap={1} paddingLeft={2}>
<Button label={`${label}`} />
<Button label={`${label}`} />
<Button label={`${label}`} />
</Box>
</Box>
{await next(e)}
</Box>
)
})
// the pane: open it with $.ui.open({ id: 'my-pane', title: "Lessons" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Button } = $.ui.resolve(e)
const proposed = '…'
const text = '…'
const sourceLabel = '…'
const evidence = '…'
const addLabel = '…'
const text2 = '…'
const sourceLabel2 = '…'
const evidence2 = '…'
const text3 = '…'
const sourceLabel3 = '…'
const evidence3 = '…'
const text4 = '…'
const whereLabel = '…'
const sourceLabel4 = '…'
const day = '…'
const text5 = '…'
const whereLabel2 = '…'
const sourceLabel5 = '…'
const day2 = '…'
const text6 = '…'
const whereLabel3 = '…'
const sourceLabel6 = '…'
const day3 = '…'
const r = '…'
const r2 = '…'
const r3 = '…'
return (
<Box flexDirection="column">
<Text bold wrap="wrap">
memo
{" Lessons "}
<Text dimColor>
{"· "}
{proposed}
/
6
{" proposals this session"}
</Text>
</Text>
<Text>
{" "}
</Text>
<Text bold>
Pending
</Text>
<Text dimColor wrap="wrap">
Nothing waiting. Your corrections and the errors Claude fixes show up here.
</Text>
<Box flexDirection="column" marginBottom={1}>
<Text wrap="wrap">
"
{text}
{"\" "}
<Text dimColor>
{"· from "}
{sourceLabel}
{" · all projects"}
</Text>
</Text>
<Text dimColor wrap="wrap">
{" "}
{evidence}
</Text>
<Box flexDirection="row" flexWrap="wrap" columnGap={1}>
<Button label={`${addLabel}`} variant="primary" />
<Button label="This session only" />
<Button label="No" dimColor />
</Box>
</Box>
<Box flexDirection="column" marginBottom={1}>
<Text wrap="wrap">
"
{text2}
{"\" "}
<Text dimColor>
{"· from "}
{sourceLabel2}
{" · all projects"}
</Text>
</Text>
<Text dimColor wrap="wrap">
{" "}
{evidence2}
</Text>
<Box flexDirection="row" flexWrap="wrap" columnGap={1}>
<Button label={`${addLabel}`} variant="primary" />
<Button label="This session only" />
<Button label="No" dimColor />
</Box>
</Box>
<Box flexDirection="column" marginBottom={1}>
<Text wrap="wrap">
"
{text3}
{"\" "}
<Text dimColor>
{"· from "}
{sourceLabel3}
{" · all projects"}
</Text>
</Text>
<Text dimColor wrap="wrap">
{" "}
{evidence3}
</Text>
<Box flexDirection="row" flexWrap="wrap" columnGap={1}>
<Button label={`${addLabel}`} variant="primary" />
<Button label="This session only" />
<Button label="No" dimColor />
</Box>
</Box>
<Text>
{" "}
</Text>
<Text bold>
Learned
</Text>
<Text dimColor>
None yet.
</Text>
<Text wrap="wrap">
<Text color="cyan">
•
</Text>
{" "}
{text4}
{" "}
<Text dimColor>
{"· "}
{whereLabel}
{" · from "}
{sourceLabel4}
{" · "}
{day}
</Text>
</Text>
<Text wrap="wrap">
<Text color="cyan">
•
</Text>
{" "}
{text5}
{" "}
<Text dimColor>
{"· "}
{whereLabel2}
{" · from "}
{sourceLabel5}
{" · "}
{day2}
</Text>
</Text>
<Text wrap="wrap">
<Text color="cyan">
•
</Text>
{" "}
{text6}
{" "}
<Text dimColor>
{"· "}
{whereLabel3}
{" · from "}
{sourceLabel6}
{" · "}
{day3}
</Text>
</Text>
<Text>
{" "}
</Text>
<Text bold>
Rejected
</Text>
<Text dimColor wrap="wrap">
None. A rejected lesson is never proposed again.
</Text>
<Box flexDirection="row" columnGap={1}>
<Box flexShrink={1} flexGrow={1}>
<Text dimColor wrap="wrap">
{r}
</Text>
</Box>
<Button label="Forget" dimColor />
</Box>
<Box flexDirection="row" columnGap={1}>
<Box flexShrink={1} flexGrow={1}>
<Text dimColor wrap="wrap">
{r2}
</Text>
</Box>
<Button label="Forget" dimColor />
</Box>
<Box flexDirection="row" columnGap={1}>
<Box flexShrink={1} flexGrow={1}>
<Text dimColor wrap="wrap">
{r3}
</Text>
</Box>
<Button label="Forget" dimColor />
</Box>
<Box marginTop={1}>
<Button hotkey="x" role="dismiss" label="Close" />
</Box>
</Box>
)
})
on('session.start', async ($, e, next) => {
const glyphOf = '…'
const label = '…'
await $.ui.toast(`${glyphOf} Claude will follow this for the rest of the session.`)
await $.ui.toast(`Already in ${label}.`)
return next(e)
})
}
Mod 自身のコード
Mod のライセンス(MIT)に従って載せています。全文は下にあります。写すときは著作権表示を残してください。
mods/ambient/lesson-learner/hooks/register.tsx 470〜500 行 · バンド
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if (e.props.hasSurvey || e.props.isWorking || e.props.view.agentId !== undefined) return next(e)
const queue = await read($, queueAtom)
const first = queue[0]
if (first === undefined) return next(e)
const { Box, Text, Button } = $.ui.resolve(e)
const below = await next(e)
const make = { Box, Text, Button } as unknown as BandMake
const mode = e.surface === 'terminal' ? glyphMode : 'full'
return band(
make,
[
{
key: 'lesson-learner-proposal',
tone: 'ask',
icon: GLYPHS.memo,
title: 'Learn this?',
text: `"${oneLine(first.text, 400)}"`,
...(queue.length > 1 ? { note: `+${queue.length - 1} more` } : {}),
actions: [
{ key: 'lesson-add', label: addLabel(first.scope), isPrimary: true, onPress: () => void accept($, first.id, 'file') },
{ key: 'lesson-session', label: 'This session only', onPress: () => void accept($, first.id, 'session') },
{ key: 'lesson-no', label: 'No', isQuiet: true, isDismiss: true, onPress: () => void reject($, first.id) },
],
},
],
e.props.bodyColumns,
below,
mode,
)
})mods/ambient/lesson-learner/hooks/band.ts 113〜116 行 · バンド
export function band(make: BandMake, rows: readonly BandRow[], columns: number, below?: RenderElement | null, glyphs: BandGlyphs = 'full'): RenderElement {
const drawn = rows.map(r => bandRow(make, r, columns, glyphs))
return make.Box({ flexDirection: 'column', children: isNothing(below) ? drawn : [...drawn, below as RenderElement] })
}mods/ambient/lesson-learner/hooks/band.ts 66〜106 行 · バンド
export function bandRow(make: BandMake, row: BandRow, columns: number, glyphs: BandGlyphs = 'full'): RenderElement {
const tone = TONES[row.tone]
const mark = glyphs === 'full' && row.icon ? row.icon[0] : tone.glyph
const actions = row.actions ?? []
const buttons = actions.reduce((n, a) => n + buttonWidth(a) + 1, 0)
// a full icon (an emoji, say) may take two cells
const markWidth = glyphs === 'full' && row.icon ? 3 : 2
const head = row.title ? row.title.length + 3 : 0
const tail = row.note ? row.note.length + 3 : 0
const isStacked = actions.length > 0 && columns - markWidth - buttons - head - tail < 24
const lines = Math.max(1, row.maxLines ?? 2)
// the first line shares its width with the glyph, the title, the note and (beside it) the buttons; the others have it all
const firstLine = Math.max(10, columns - markWidth - (isStacked ? 0 : buttons) - head - tail)
const room = firstLine + (lines - 1) * Math.max(10, columns - markWidth)
const children: RenderElement[] = []
if (row.title) children.push(make.Text({ bold: true, children: [row.title] }), make.Text({ dimColor: true, children: [' · '] }))
children.push(make.Text({ children: [clipText(row.text, room)] }))
if (row.note) children.push(make.Text({ dimColor: true, children: [` · ${row.note}`] }))
const glyph = make.Text({ color: tone.color, bold: true, children: [mark] })
const text = make.Box({ flexShrink: 1, flexGrow: 1, children: [make.Text({ wrap: 'wrap', children })] })
const drawn = actions.map(a =>
make.Button({
key: a.key,
label: a.label,
...(a.hotkey ? { hotkey: a.hotkey } : {}),
...(a.isPrimary ? { variant: 'primary' } : {}),
...(a.isQuiet ? { dimColor: true } : {}),
...(a.isDismiss ? { role: 'dismiss' } : {}),
onPress: a.onPress,
}),
)
if (!isStacked) return make.Box({ key: row.key, flexDirection: 'row', columnGap: 1, children: [glyph, text, ...drawn] })
return make.Box({
key: row.key,
flexDirection: 'column',
children: [
make.Box({ flexDirection: 'row', columnGap: 1, children: [glyph, text] }),
make.Box({ flexDirection: 'row', flexWrap: 'wrap', columnGap: 1, paddingLeft: 2, children: drawn }),
],
})
}mods/ambient/lesson-learner/hooks/register.tsx 504〜570 行 · ペイン
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
const { Box, Text, Button } = $.ui.resolve(e)
const queue = await read($, queueAtom)
const learned = await read($, learnedAtom)
const rejected = await read($, rejectedAtom)
const proposed = await read($, proposedAtom)
const mode = e.surface === 'terminal' ? glyphMode : 'full'
return (
<Box flexDirection="column">
<Text bold wrap="wrap">
{glyphOf('memo', mode)} Lessons <Text dimColor>· {proposed}/{MAX_PROPOSALS} proposals this session</Text>
</Text>
<Text> </Text>
<Text bold>Pending</Text>
{queue.length === 0 && <Text dimColor wrap="wrap">Nothing waiting. Your corrections and the errors Claude fixes show up here.</Text>}
{queue.map(c => (
<Box key={`pending:${c.id}`} flexDirection="column" marginBottom={1}>
<Text wrap="wrap">
"{c.text}" <Text dimColor>· from {sourceLabel(c.source)}{c.scope === 'global' ? ' · all projects' : ''}</Text>
</Text>
<Text dimColor wrap="wrap">
{' '}
{c.evidence}
</Text>
<Box flexDirection="row" flexWrap="wrap" columnGap={1}>
<Button key={`add:${c.id}`} label={addLabel(c.scope)} variant="primary" onPress={() => void accept($, c.id, 'file')} />
<Button key={`session:${c.id}`} label="This session only" onPress={() => void accept($, c.id, 'session')} />
<Button key={`no:${c.id}`} label="No" dimColor onPress={() => void reject($, c.id)} />
</Box>
</Box>
))}
<Text> </Text>
<Text bold>Learned</Text>
{learned.length === 0 && <Text dimColor>None yet.</Text>}
{[...learned]
.reverse()
.slice(0, 30)
.map((l, i) => (
<Text key={`learned:${i}`} wrap="wrap">
<Text color="cyan">•</Text> {l.text}{' '}
<Text dimColor>
· {whereLabel(l.where)} · from {sourceLabel(l.source)} · {day(l.at)}
</Text>
</Text>
))}
<Text> </Text>
<Text bold>Rejected</Text>
{rejected.length === 0 && <Text dimColor wrap="wrap">None. A rejected lesson is never proposed again.</Text>}
{[...rejected]
.reverse()
.slice(0, 20)
.map((r, i) => (
<Box key={`rejected:${i}`} flexDirection="row" columnGap={1}>
<Box flexShrink={1} flexGrow={1}>
<Text dimColor wrap="wrap">
{r}
</Text>
</Box>
<Button key={`forget:${i}`} label="Forget" dimColor onPress={() => void forget($, r)} />
</Box>
))}
<Box marginTop={1}>
<Button key="close" hotkey="x" role="dismiss" label="Close" onPress={() => void $.ui.close({ id: PANE })} />
</Box>
</Box>
)
})ライセンスの全文(MIT)
MIT License Copyright (c) 2026 mako-code Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
コードが呼ぶもの
ファイル書き込み環境変数Claude を動かすツール呼び出し保存
コードから読み取ったデザイン
読み取ったコミットのソースから描いたもので、動かした結果ではありません。一覧は 3 回描き、条件はデスクトップアプリで描く最初の分岐を取り、動かしたときにだけ決まる値は仮の例(点線の下線)にするか省きます。色と書体はこのサイトのものです。
コードから読めること
2026-10-06 に読んだコミット ec6ea2383749 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。
| 載せる条件: 確かめやすいコード | |
|---|---|
| 入口を読んだ | hooks/hooks.json が名指すモジュールをすべて読んだ。mods/ambient/lesson-learner/hooks/register.tsx |
| 解析できる | すべてのファイルが TypeScript か JavaScript として解析できる。4 ファイルを解析 |
| コードが Mod の中で完結 | import は Mod 自身のファイルかエンジンのモジュールだけ。パッケージも require もない。コードはすべて Mod の中 |
| 読める | 圧縮した行・eval・new Function・計算した道の import()・符号化した塊がない。圧縮・eval・符号化した塊なし |
| 呼び出しが見える | 通信とプログラム起動はその場で $.http.fetch・$.process.run と書き、他へ渡さない。外への呼び出しはすべてその場の $ で |
| 入れる前に自分で判断する材料 | |
| 描く場所 | コードから読んだ、描く先。ターミナル・デスクトップアプリ・両方・何も描かない(フックだけ: 見張りやプロンプトの書き換え)のどれか。出すだけで、外す理由にはしない。ターミナルとデスクトップアプリに同じように描く |
| 入れる手順 | リポジトリ自身の .claude-plugin/marketplace.json にこの Mod が載っていて、ページに書いた手順でそのマーケットプレイスから入れられるか。リポジトリの .claude-plugin/marketplace.json に載っており、そこから入れられる |
| Windows のプログラム | $.process で起動するプログラムが Windows にあるか(tail・date・open・osascript・/usr/… などは無い)。Windows にないプログラムを使わない |
| 通信 | fetch の送り先(https のホスト)がコードに書いてあるか。通信なし |
| プログラム | 起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。プログラムを起動しない |
| 読んで送る | ファイルや環境変数を読み、かつ通信するか。通信しない |
| ソースの鍵 | ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし |
| ライセンス | オープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT |
コードの文面を読んだだけで、安全の審査ではありません。動かしてはおらず、起動するプログラムの中で何が起きるかも見えません。入れる前の確認はあなたの役目です。 載せる条件
入れる
入れる前に、必ず自分で確かめてください。Mod はサンドボックスなしで、あなたの権限で動きます。modscode はこのコードの安全を保証しません。下のコードを読み(またはフォルダーで claude plugin validate .)、触るものを見て、読んだコミットを入れてください。
リポジトリがそのままマーケットプレイスです。このマーケットプレイスを足し(ターミナルでは次のコマンド、デスクトップアプリではプラグインの設定)、そこから Mod を入れます。
/plugin marketplace add mako-code/gobworks/plugin install lesson-learner@gobworks入るのはマーケットプレイスの最新のコミットで、ここで読んだもの(ec6ea2383749)と違うことがあります。入れる前に見比べてください。
Claude に聞く
modscode のコネクタを入れると、Claude がこのデザイン・コードが触るもの・コードを読んで、それをもとに作れます。たとえば:
modscode のデザイン「mako-code-lesson-learner」をコードごと読んで、同じようなペインを作って似たデザイン
-
Claude に頼む…2h 10m · █████░░░✓ build ✓ build ✓ buildJavaKotlin3 Python■ ok 3 ■ ok 3 ■ ok 3 Razor proven 3 Razor proven 3 Razor proven 3Phases ──────── 3/3build Pythonbuild Pythonbuild Python… 3 more phasesLua ──────── 3/Kotlin■ the whole upgrade Ruby■ build build Ruby■ build build Ruby■ build build Ruby … 3 moreNext ──────── PythonRuby (by hand)Podsclick a button, or ctrl+x tab then Tab, EnterAttention ──────── 3! Scala ! Scala ! Scala … 3 moreSession ──────── okJava
-
Open a file first: /crit-tui file <path>Reopen this one in the crit browser view.Claude に頼む…
-
Claude に頼む…TodayOct 63 left · Mar overdueRemCTL: Sep✓ All done for today.● build3● Fix login ● ⚑Jul · build✓● Fix login ● ⚑Jul · build✓● Fix login ● ⚑Jul · build✓● build3● Fix login ● ⚑Jul · build✓● Fix login ● ⚑Jul · build✓● Fix login ● ⚑Jul · build✓● build3● Fix login ● ⚑Jul · build✓● Fix login ● ⚑Jul · build✓● Fix login ● ⚑Jul · build✓Updated 14:32UndoRefresh
-
Claude に頼む…TO graph› Fix login › Fix login › Fix loginScopeThis featureWhole projectHide done stepsReconnect
-
Claude に頼む…Blast Radius⚠ Blast Radius · buildCommand npm testWould CancelProceed Proceed ProceedBash1 Proceed2 CancelClaude is waiting on your answer
-
Claude に頼む…Agent Radar● Edit note · 2h 10m · 0 toolsnow: starting────────No messages yet.agent: (tool calls)agent: (tool calls)agent: (tool calls)Back bClose q