SLOPSHOPPER

artifact-archive

一時ディレクトリ (tmp/scratchpad) からの Artifact publish を拒否し ~/Documents/claude-artifacts への保存へ誘導する

newguard
★ 1v0.1.0no licenseupdated 2026-09-22void2610/dotfiles/.claude/mods/artifact-archive
A shopper browsing a rack in a slop shop
README

dotfiles

個人用のdotfiles設定リポジトリです。 パッケージ管理と Homebrew 管理は別の nix-config リポジトリで行い、このリポジトリは主にシェルやアプリ設定を管理します。

セットアップ手順

1. リポジトリのクローン

git clone https://github.com/yourusername/dotfiles.git ~/dotfiles
cd ~/dotfiles

2. Nix / nix-darwin 設定の適用

cd ~/nix-config
darwin-rebuild switch --flake .#<nix-configで定義したホスト名>

3. dotfilesのシンボリックリンク作成

./install.sh

既存の設定ファイルは~/backupディレクトリにバックアップされます。

ファイル構成

  • install.sh: dotfilesのシンボリックリンク作成スクリプト
  • MANUAL_APPS.md: 手動インストールが必要なアプリケーション一覧
  • .config/: 各種アプリケーションの設定ファイル
  • .zshrc: Zshシェルの設定
  • .gitconfig: Git設定
  • .tmux.conf: tmux設定
  • .claude/: Claude Code の設定
  • .codex/: Codex の設定
Source 1 files
hooks/index.ts 23 lines
1import type { Register } from "claude-code";
2
3const ARCHIVE_DIR = "~/Documents/claude-artifacts";
4
5// scratchpad (/private)/tmp 配下は セッション終了で消えるため配信元にさせない
6const EPHEMERAL = /^\/(private\/)?(tmp|var\/folders)\//;
7
8type ArtifactArgs = { action?: string; file_path?: string; asset?: boolean };
9
10export const register: Register = (on) => {
11  // 生成型の tool union に Artifact が無いため RegExp matcher で束縛する
12  on("tool.call", { tool: /^Artifact$/ }, (_$, e, next) => {
13    const args = e as unknown as ArtifactArgs;
14    const isPublish = (args.action ?? "publish") === "publish" && !args.asset;
15    if (isPublish && args.file_path && EPHEMERAL.test(args.file_path)) {
16      return {
17        deny: `一時ディレクトリからの publish は禁止。ファイルを ${ARCHIVE_DIR}/ へ内容が分かる kebab-case 名で保存し直し、そこから publish し直すこと (セッション終了後もソースを残すため)。`,
18      };
19    }
20    return next(e);
21  });
22};
23