modscode EN

modscode / 図鑑 / familiar

familiar

A pixel-art companion above the prompt that reacts to your session, levels up, and can be redrawn by hand

確かめやすいコードターミナル+デスクトップペインバンドトーストBoxButtonClientText

何をするか

  • プロンプトの上の帯・欄・トーストを描く
  • /familiar を足す
  • ツールの呼び出しを見張る(止めることがある)
  • session.measure・session.start・turn.complete・turn.start ほか 1 個にフックする
  • ターンをまたいで自分の状態を持つ

良いところ

  • ネットワークに出ない
  • プロセスを起こさない
  • TypeScript で書かれている
  • デスクトップ専用の分岐がある

作り始めるためのコード

2 種類あります。上のデザインから modscode が書いた雛形と、その Mod 自身のコードのうち描いている部分です。

雛形(register.tsx)

register.tsx
import type { Register } from 'claude-code'

// Drawn like familiar by Nafees S (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/lucenity0-familiar/
// 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 } = $.ui.resolve(e)
    const glyph = '…'
    const glyph2 = '…'
    const glyph3 = '…'
    const glyph4 = '…'
    const glyph5 = '…'
    const glyph6 = '…'
    const glyph7 = '…'
    const glyph8 = '…'
    const glyph9 = '…'
    const footer = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="row" columnGap={2} paddingLeft={1} marginTop={1}>
          <Box flexDirection="column">
            <Text>
              <Text>
                {glyph}
              </Text>
              <Text>
                {glyph2}
              </Text>
              <Text>
                {glyph3}
              </Text>
            </Text>
            <Text>
              <Text>
                {glyph4}
              </Text>
              <Text>
                {glyph5}
              </Text>
              <Text>
                {glyph6}
              </Text>
            </Text>
            <Text>
              <Text>
                {glyph7}
              </Text>
              <Text>
                {glyph8}
              </Text>
              <Text>
                {glyph9}
              </Text>
            </Text>
          </Box>
          <Box flexDirection="column" justifyContent="center">
            <Text>
              {" "}
            </Text>
            <Text dimColor>
              {footer}
            </Text>
          </Box>
        </Box>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "Pick a look for ‹name›" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const glyph = '…'
    const glyph2 = '…'
    const glyph3 = '…'
    const glyph4 = '…'
    const glyph5 = '…'
    const glyph6 = '…'
    const glyph7 = '…'
    const glyph8 = '…'
    const glyph9 = '…'
    const i = '…'
    const glyph10 = '…'
    const glyph11 = '…'
    const glyph12 = '…'
    const glyph13 = '…'
    const glyph14 = '…'
    const glyph15 = '…'
    const glyph16 = '…'
    const glyph17 = '…'
    const glyph18 = '…'
    const glyph19 = '…'
    const glyph20 = '…'
    const glyph21 = '…'
    const glyph22 = '…'
    const glyph23 = '…'
    const glyph24 = '…'
    const glyph25 = '…'
    const glyph26 = '…'
    const glyph27 = '…'
    return (
      <Box flexDirection="column" rowGap={1}>
        <Box flexDirection="row" flexWrap="wrap" columnGap={3} rowGap={1}>
          <Box flexDirection="column" alignItems="center" rowGap={1}>
            <Box flexDirection="column">
              <Text>
                <Text>
                  {glyph}
                </Text>
                <Text>
                  {glyph2}
                </Text>
                <Text>
                  {glyph3}
                </Text>
              </Text>
              <Text>
                <Text>
                  {glyph4}
                </Text>
                <Text>
                  {glyph5}
                </Text>
                <Text>
                  {glyph6}
                </Text>
              </Text>
              <Text>
                <Text>
                  {glyph7}
                </Text>
                <Text>
                  {glyph8}
                </Text>
                <Text>
                  {glyph9}
                </Text>
              </Text>
            </Box>
            <Button label="clawd" hotkey={`${i}`} />
          </Box>
          <Box flexDirection="column" alignItems="center" rowGap={1}>
            <Box flexDirection="column">
              <Text>
                <Text>
                  {glyph10}
                </Text>
                <Text>
                  {glyph11}
                </Text>
                <Text>
                  {glyph12}
                </Text>
              </Text>
              <Text>
                <Text>
                  {glyph13}
                </Text>
                <Text>
                  {glyph14}
                </Text>
                <Text>
                  {glyph15}
                </Text>
              </Text>
              <Text>
                <Text>
                  {glyph16}
                </Text>
                <Text>
                  {glyph17}
                </Text>
                <Text>
                  {glyph18}
                </Text>
              </Text>
            </Box>
            <Button label="clawd" hotkey={`${i}`} />
          </Box>
          <Box flexDirection="column" alignItems="center" rowGap={1}>
            <Box flexDirection="column">
              <Text>
                <Text>
                  {glyph19}
                </Text>
                <Text>
                  {glyph20}
                </Text>
                <Text>
                  {glyph21}
                </Text>
              </Text>
              <Text>
                <Text>
                  {glyph22}
                </Text>
                <Text>
                  {glyph23}
                </Text>
                <Text>
                  {glyph24}
                </Text>
              </Text>
              <Text>
                <Text>
                  {glyph25}
                </Text>
                <Text>
                  {glyph26}
                </Text>
                <Text>
                  {glyph27}
                </Text>
              </Text>
            </Box>
            <Button label="clawd" hotkey={`${i}`} />
          </Box>
        </Box>
        <Text dimColor>
          {"draw your own with /familiar draw. "}
          esc closes
        </Text>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const sprite = '…'
    await $.ui.toast(`Could not save: ${sprite}`)
    await $.ui.toast(`Saved. /familiar export prints it to share.`)
    return next(e)
  })
}

Mod 自身のコード

Mod のライセンス(MIT)に従って載せています。全文は下にあります。写すときは著作権表示を残してください。

hooks/register.tsx 348〜391 行 · バンド
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const p = await read($, profile)
    if (p === null || e.props.hasSurvey || (await read($, isHidden))) return next(e)

    const { view } = await read($, mind)
    const level = levelFor(p.xp)
    const footer = `${p.name} · ${view.mood} · lvl ${level}`
    const { Box, Text } = $.ui.resolve(e)

    const sprite = spriteOf(p)
    const { top, bottom } = bandRows(sprite)
    const age = Math.max(0, Math.floor(((await $.clock.now()) - view.since) / FRAME_MS))
    const pixels = frame(sprite, view.mood, await read($, tick), level, age)
    // Full size while you read or type; half size while Claude's output streams or the window is short.
    const isRoomy = !e.props.isWorking && (e.viewport?.rows ?? TALL_ROWS) >= TALL_ROWS
    const wanted: SpriteSize = size === 'auto' ? (isRoomy ? 'full' : 'compact') : size
    const fits = (cells: Cell[][]) => e.props.bodyColumns >= (cells[0]?.length ?? 0) + 24 && e.props.maxRows >= cells.length + 1
    const full = wanted === 'full' ? fullCells(pixels, top, bottom) : null
    const cells = full !== null && fits(full) ? full : compactCells(pixels, top, bottom)
    if (!fits(cells)) {
      return (
        <Box marginTop={1} paddingLeft={1}>
          <Text>
            {FACES[view.mood]} <Text dimColor>{p.name}</Text>
            {view.line === '' ? '' : `  ${view.line}`}
          </Text>
        </Box>
      )
    }

    const words = (
      <Box flexDirection="column" justifyContent="center">
        <Text>{view.line === '' ? ' ' : view.line}</Text>
        <Text dimColor>{footer}</Text>
      </Box>
    )

    return (
      <Box flexDirection="row" columnGap={2} paddingLeft={1} marginTop={1}>
        {picture($, e, 'sprite', cells)}
        {words}
      </Box>
    )
  })
hooks/register.tsx 90〜113 行 · バンド
function picture($: EngineInterface, e: ResolveInput, key: string, cells: Cell[][]) {
  if (e.surface === 'terminal') {
    const { Raster } = $.ui.resolve(e)
    return <Raster key={key} columns={cells[0]?.length ?? 0} rows={cells.length} cells={rasterCells(cells)} />
  }
  const { Box, Text } = $.ui.resolve(e)
  return (
    <Box key={key} flexDirection="column">
      {cells.map(row => (
        <Text>
          {row.map(cell =>
            cell.bg === null ? (
              <Text {...(cell.fg === null ? {} : { color: cell.fg })}>{cell.glyph}</Text>
            ) : (
              <Text color={cell.fg ?? '#000000'} backgroundColor={cell.bg}>
                {cell.glyph}
              </Text>
            ),
          )}
        </Text>
      ))}
    </Box>
  )
}
hooks/register.tsx 393〜434 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PICK_PANE }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const p = await read($, profile)
    if (p === null) return <Text dimColor>No familiar yet.</Text>

    const looks: { species: Species; sprite: Sprite }[] = [
      ...BUILT_IN.map(species => ({ species, sprite: SPECIES[species] })),
      ...(p.custom === null ? [] : [{ species: 'custom' as const, sprite: p.custom }]),
    ]
    // Full size has no seams in any terminal; the lineup drops to half size only when it would not fit.
    const perRow = Math.max(1, Math.floor((e.props.bodyColumns + 3) / (WIDTH * 2 + 3)))
    const tallest = Math.max(...looks.map(look => usedRows(look.sprite).bottom - usedRows(look.sprite).top + 1))
    const needed = Math.ceil(looks.length / perRow) * (tallest + 3) + 1
    const size: SpriteSize = needed <= e.props.scroll.bodyRows ? 'full' : 'compact'
    const choose = async (species: Species) => {
      await saveProfile($, current => ({ ...current, species }))
      await $.ui.close({ id: PICK_PANE })
      await say($, 'happy', 'how do i look?')
    }

    return (
      <Box flexDirection="column" rowGap={1}>
        <Box flexDirection="row" flexWrap="wrap" columnGap={3} rowGap={1}>
          {looks.map(({ species, sprite }, i) => (
            <Box key={species} flexDirection="column" alignItems="center" rowGap={1}>
              {picture($, e, `look-${species}`, preview(sprite, size))}
              <Button
                key={`pick-${species}`}
                label={species}
                hotkey={String(i + 1)}
                {...(species === p.species ? { variant: 'primary' as const } : { dimColor: true })}
                onPress={() => choose(species)}
              />
            </Box>
          ))}
        </Box>
        <Text dimColor>
          {p.custom === null ? 'draw your own with /familiar draw. ' : ''}esc closes
        </Text>
      </Box>
    )
  })
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Nafees S

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 に読んだコミット 77930064d562 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。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 lucenity0/claude-familiar
/plugin install familiar@claude-familiar

入るのはマーケットプレイスの最新のコミットで、ここで読んだもの(77930064d562)と違うことがあります。入れる前に見比べてください。

Claude に聞く

modscode のコネクタを入れると、Claude がこのデザイン・コードが触るもの・コードを読んで、それをもとに作れます。たとえば:

modscode のデザイン「lucenity0-familiar」をコードごと読んで、同じようなペインを作って

Claude から探す: MCP コネクタ

似たデザイン