modscode EN

modscode / 図鑑 / commit-craft

commit-craft

Commit messages in your repository's own style (learned from its last 30 subjects) and pull request descriptions from the branch, drafted by haiku; nothing is committed or pushed without a press.

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

何をするか

  • 欄・トーストを描く
  • /commit-craft・/pr-desc を足す
  • session.startにフックする
  • プロセスを起こす

良いところ

  • ネットワークに出ない
  • TypeScript で書かれている
  • エラーを扱う

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like commit-craft by mako-code (pane, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/mako-code-commit-craft/
// 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 pane: open it with $.ui.open({ id: 'my-pane', title: "Commit message" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const title = '…'
    const context = '…'
    const facts = '…'
    const subject = '…'
    const body = '…'
    const length = '…'
    const error = '…'
    const committed = '…'
    const spent = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="column">
          <Text bold>
            {title}
          </Text>
          <Text dimColor wrap="wrap">
            {`Style: ${context}`}
          </Text>
          <Text dimColor wrap="wrap">
            {facts}
          </Text>
        </Box>
        <Box marginTop={1} flexDirection="column">
          <Text bold wrap="wrap">
            {subject}
          </Text>
          <Text wrap="wrap" dimColor>
            {body}
          </Text>
        </Box>
        <Text color="yellow">
          {`The subject is ${length} characters (most tools cut at 72).`}
        </Text>
        <Text color="red" wrap="wrap">
          {error}
        </Text>
        <Text color="green">
          {`Committed ${committed}.`}
        </Text>
        <Text dimColor>
          Committing…
        </Text>
        <Text dimColor>
          {spent}
        </Text>
        <Box gap={1} marginTop={1} flexWrap="wrap">
          <Button hotkey="c" variant="primary" label="Commit" />
          <Button hotkey="e" label="Edit" />
          <Button hotkey="r" label="Try again" />
          <Button hotkey="y" label="Copy" />
          <Button hotkey="x" role="dismiss" label="Close" />
        </Box>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const reason = '…'
    const head = '…'
    const subjectOf = '…'
    await $.ui.toast(`The pane is waiting (${reason})`)
    await $.ui.toast(`Committed ${head}: ${subjectOf}`)
    return next(e)
  })
}

Mod 自身のコード

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

mods/tandem/commit-craft/hooks/register.tsx 469〜612 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const { Box, Text, Button, Markdown } = $.ui.resolve(e)
    const view = await read($, viewAtom)
    const draft = view === 'commit' ? await read($, commitAtom) : await read($, prAtom)
    const close = <Button key="close" hotkey="x" role="dismiss" label="Close" onPress={() => quietly($.ui.close({ id: PANE }))} />
    if (draft === null) {
      return (
        <Box flexDirection="column">
          <Text bold>Commit craft</Text>
          <Text dimColor wrap="wrap">Run /commit-craft for a commit message, or /pr-desc for a pull request description.</Text>
          <Box marginTop={1}>{close}</Box>
        </Box>
      )
    }
    const kind = draft.kind
    const title = kind === 'commit' ? 'Commit message' : 'PR description'
    const spent = draft.calls > 0 ? `${draft.model} · ${plural(draft.calls, 'call')} · ${fmtTokens(draft.input)} in / ${fmtTokens(draft.output)} out · ${fmtUsd(draft.usd)}` : ''
    const regen = <Button key="regenerate" hotkey="r" label={draft.status === 'failed' ? 'Try again' : 'Regenerate'} onPress={() => quietly(regenerate($, kind))} />

    if (draft.status === 'nothing-staged') {
      return (
        <Box flexDirection="column">
          <Text bold>{title}</Text>
          <Text wrap="wrap">Nothing is staged. Stage what belongs in the commit (git add …), then run /commit-craft again.</Text>
          {draft.gitStatus !== '' && (
            <Box flexDirection="column" marginTop={1}>
              {draft.gitStatus.split('\n').slice(0, 40).map(line => (
                <Text wrap="truncate-end">{line === '' ? ' ' : line}</Text>
              ))}
            </Box>
          )}
          <Box gap={1} marginTop={1} flexWrap="wrap">
            <Button key="status" hotkey="g" variant="primary" label="Show git status" onPress={() => quietly(showGitStatus($))} />
            <Button key="regenerate" hotkey="r" label="Check again" onPress={() => quietly(regenerate($, 'commit'))} />
            {close}
          </Box>
        </Box>
      )
    }

    const head = (
      <Box flexDirection="column">
        <Text bold>{title}</Text>
        {draft.context !== '' && (
          <Text dimColor wrap="wrap">
            {kind === 'commit' ? `Style: ${draft.context}` : draft.context}
          </Text>
        )}
        {draft.facts !== '' && (
          <Text dimColor wrap="wrap">
            {draft.facts}
          </Text>
        )}
      </Box>
    )

    if (draft.status === 'drafting' || draft.status === 'failed') {
      return (
        <Box flexDirection="column">
          {head}
          {draft.status === 'drafting' ? <Text dimColor>{draft.progress || 'Working…'}</Text> : <Text color="red" wrap="wrap">{draft.error}</Text>}
          {spent !== '' && <Text dimColor>{spent}</Text>}
          <Box gap={1} marginTop={1} flexWrap="wrap">
            {draft.status === 'failed' && regen}
            {close}
          </Box>
        </Box>
      )
    }

    const copy = <Button key="copy" hotkey="y" label="Copy" onPress={press => quietly(copyDraft($, kind, press.surface))} />
    const edit = <Button key="edit" hotkey="e" label="Edit" onPress={press => quietly(editInPrompt($, kind, press.surface))} />

    if (kind === 'pr') {
      return (
        <Box flexDirection="column">
          {head}
          <Box marginTop={1} flexDirection="column">
            <Markdown text={draft.text.length > MARKDOWN_CHARS ? `${draft.text.slice(0, MARKDOWN_CHARS)}\n\n…` : draft.text} />
          </Box>
          <Text dimColor>{spent}</Text>
          <Text dimColor wrap="wrap">
            Nothing is pushed or opened: copy it, or Edit to ask Claude to open the pull request with it.
          </Text>
          <Box gap={1} marginTop={1} flexWrap="wrap">
            {copy}
            {edit}
            {regen}
            {close}
          </Box>
        </Box>
      )
    }

    const lines = draft.text.split('\n')
    const subject = lines[0] ?? ''
    const body = lines.slice(1).join('\n').replace(/^\n+/, '')
    let field: JSX.Element | null = null
    if (e.surface !== 'mobile' && draft.status === 'ready') {
      const { Input } = $.ui.resolve(e)
      field = (
        <Input
          key="subject"
          label="Subject "
          value={subject}
          submitLabel="keep"
          onInput={value => quietly(typeSubject($, value))}
          onSubmit={value => quietly(typeSubject($, value))}
        />
      )
    }
    return (
      <Box flexDirection="column">
        {head}
        <Box marginTop={1} flexDirection="column">
          <Text bold wrap="wrap">
            {subject}
          </Text>
          {body !== '' && (
            <Text wrap="wrap" dimColor>
              {body}
            </Text>
          )}
        </Box>
        {field}
        {subject.length > 72 && <Text color="yellow">{`The subject is ${subject.length} characters (most tools cut at 72).`}</Text>}
        {draft.error !== '' && (
          <Text color="red" wrap="wrap">
            {draft.error}
          </Text>
        )}
        {draft.status === 'committed' && <Text color="green">{`Committed ${draft.committed}.`}</Text>}
        {draft.status === 'committing' && <Text dimColor>Committing…</Text>}
        <Text dimColor>{spent}</Text>
        <Box gap={1} marginTop={1} flexWrap="wrap">
          {draft.status === 'ready' && <Button key="commit" hotkey="c" variant="primary" label="Commit" onPress={() => quietly(commitNow($))} />}
          {draft.status === 'ready' && edit}
          {draft.status === 'ready' && regen}
          {copy}
          {close}
        </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/tandem/commit-craft/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 のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。mods/tandem/commit-craft/hooks/register.tsx:389 powershell(シェル・インタプリタ); mods/tandem/commit-craft/hooks/register.tsx:396 実行時に決まるプログラム
読んで送るファイルや環境変数を読み、かつ通信するか。reads environment variables and files and reaches the network
ソースの鍵ソースに 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 commit-craft@gobworks

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン