Communitygithub.com

config-gc

Claude Code設定のガベージコレクション。~/.claude(スキル、メモリ、フック、権限、MCPサーバー、キャッシュ)を定期的にスキャンし、冗長、古い、孤立した、または価値の低いアイテムを特定し、ユーザーが一つ一つ確認して削除するクリーンアップを実行します。

config-gc とは?

このスキル「Config GC」は、Claude Codeの設定ディレクトリ(`~/.claude`)に蓄積された冗長、古い、または孤立した設定アイテムを定期的にスキャンし、ユーザーが確認・削除できるようにするガベージコレクションツールです。スキル、メモリファイル、フック、権限エントリ、MCPサーバー、キャッシュなど8つのチャネルを個別のスキャン戦略で監査します。各削除候補に対しては常に人間の確認(`[y/n/skip]`)を求め、自動削除は行いません。削除前に`.disabled`リネームや`_gc_trash`への移動でソフトデリートを実行し、`gc_log.md`にすべての操作を記録して元に戻せるようにします。Claude Code、Cursor、CodexなどのAIエージェント環境で動作し、設定の肥大化を防ぎ、セキュリティレビューやパフォーマンス維持に貢献します。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/config-gc

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Config GC — Claude Code設定のガベージコレクション

ランタイムガベージコレクションから着想を得ています。参照されなくなったオブジェクト、冗長なオブジェクト、期限切れのオブジェクト、または価値の低いオブジェクトを定期的にスキャンし、領域を再利用します。決定的な違いは、ここでは収集に人間の介在が必要であることです。自律的に削除してはいけません。

アクティベーションのタイミング

  • ユーザーがClaude Code設定のクリーンアップ、監査、またはスリム化を依頼した場合
  • スキルが多すぎる、フックがノイズが多い、セッション起動が遅いとユーザーが不満を述べた場合
  • 月次/定期設定レビューが行われた場合
  • 大規模なスキルパック(例:このリポジトリ)をインストールした後、既存設定との重複を調整するため

以下の場合はアクティベートしないでください:プロジェクトのソースコードのクリーンアップ(それはリファクタリングです)、チャット履歴の消去、Claude Code自体のアンインストール。

設計思想

  1. 追記専用設定は漏れ出す。 スキル、メモリファイル、フック、権限エントリは追加される一方です。定期的なレビューなしに静かに腐っていきます。
  2. 1回限りのパージよりも定期的な監査の方が効果的。 約30日ごとにスキャンし、毎回少数の候補を提案します。
  3. チャネルごとに戦略を変える。 蓄積タイプ(スキル、フック、権限など)ごとに独自の陳腐化シグナルがあります。すべてに同じルールを適用しないでください。
  4. 最初はソフトデリート。 .disabled にリネーム → ~/.claude/_gc_trash/ に移動 → 実際の削除。常に元に戻す道を残してください。
  5. 強制人間介在。 各候補に対して個別の [y/n/skip] 確認を行います。「すべてはい」のショートカットはありません。
  6. ログを残す。 GCの実行ごとに ~/.claude/gc_log.md に追記します。何に触れたか、その理由、元に戻す方法を記録します。

スキャンチャネル

#チャネルパス陳腐化 / 冗長性のシグナル
1スキル~/.claude/skills/*/名前の重複がひどい;最近のトランスクリプトで一度もトリガーされていない;ユーザーの実際の作業とドメインが一致しない;SKILL.mdが壊れているか空
2メモリ~/.claude/**/memory/*.md + そのインデックス1つのトピックに複数のインデックスエントリ;新しいエントリと矛盾する内容;日付が過ぎたもの;インデックスにない孤立ファイル;マージすべき100語未満の断片
3フック~/.claude/hooks/ + 設定ディスク上に存在するが、どのフック設定からも参照されていないスクリプト;書き換えによって置き換えられた古いバージョン
4権限settings.json / settings.local.json の permissions.allow重複エントリ;ワイルドカードで既にカバーされている特定のエントリ(例:Bash(*) が許可されているのに Bash(git push) がある);過去の実験による一回限りの許可
5MCPサーバー~/.claude.json またはプロジェクトの .mcp.json接続に失敗するサーバー;機能的に重複しているもの;長期間未使用
6スケジュール済みリマインダー/ジョブユーザーが保存している場所30日以上経過した発火済みワンショット;対象スクリプトが存在しなくなったジョブ
7プロジェクト履歴~/.claude/projects/*/古いハンドオフスナップショット;新しい状態に置き換えられたセッション記録
8ランタイムキャッシュcache/, file-history/, logs/, shell-snapshots/サイズとmtimeでソート;30日以上経過した大きなアイテムを提案

ワークフロー

  1. スキャン すべてのチャネル(またはユーザーが指定したサブセット)をスキャンします。パス、チャネル、フラグを立てたシグナル、サイズ、最終更新日を収集します。
  2. ランク付け 信頼度(壊れている/孤立 = 高;単に古い = 低)でランク付けし、番号付きテーブルで提示します。各実行で約20候補に制限します。GCは定期的であり、網羅的ではありません。
  3. 1つずつ確認。 各候補について証拠を表示し、[y/n/skip] を尋ねます。ユーザーはいつでも中断できます。
  4. 確認されたアイテムをソフトデリート: スキルとフックには .disabled リネームを、ファイルには _gc_trash/<date>/ への移動を優先します。権限エントリはJSONに存在します(コメント不可):設定ファイルをバックアップし、削除した各エントリを gc_log.md にそのまま記録し、jq で allow 配列から削除します。ユーザーが明示的に要求した場合にのみハードデリートします。
  5. ログに記録 ~/.claude/gc_log.md に実行を記録します:タイムスタンプ、処理したアイテム、元に戻す手順。
  6. 報告 再利用されたサイズ、まだ正常なチャネル、推奨される次回レビュー日を報告します。

スキャンコマンド例

孤立したフックスクリプト(チャネル3) — ディスク上に存在するが、どのフック設定からも参照されていないスクリプト:

for f in ~/.claude/hooks/*; do
  name=$(basename "$f")
  grep -rq "$name" ~/.claude/settings.json ~/.claude/settings.local.json 2>/dev/null \
    || echo "ORPHAN: $f"
done

冗長な権限エントリ(チャネル4) — 重複、およびワイルドカードによって隠蔽されている特定の許可:

jq -r '.permissions.allow[]' ~/.claude/settings.local.json | sort | uniq -d
if jq -e '.permissions.allow | index("Bash(*)")' ~/.claude/settings.local.json >/dev/null; then
  jq -r '.permissions.allow[]' ~/.claude/settings.local.json \
    | grep '^Bash(' | grep -vF 'Bash(*)'
fi

最大の古いキャッシュ(チャネル8) — GNU専用の find -printf の代わりに du -k を使用するため、macOS/BSDでも動作します:

find ~/.claude/file-history ~/.claude/shell-snapshots -type f -mtime +30 \
  -exec du -k {} + 2>/dev/null | sort -rn | head -20

元に戻せるソフトデリート(日付を一度キャプチャして、ログとディレクトリが矛盾しないようにする):

gc_date=$(date +%Y-%m-%d)
mkdir -p ~/.claude/_gc_trash/$gc_date
mv ~/.claude/skills/dead-skill ~/.claude/_gc_trash/$gc_date/
echo "$(date -Iseconds) moved skills/dead-skill -> _gc_trash/$gc_date/ (undo: mv back)" >> ~/.claude/gc_log.md

確認済みの冗長な権限エントリの削除(JSONにはコメントがありません — バックアップ、ログ記録、編集):

cp ~/.claude/settings.local.json ~/.claude/settings.local.json.bak
echo "$(date -Iseconds) removed permission entry: Bash(git push) (undo: restore from .bak or re-add)" >> ~/.claude/gc_log.md
jq '.permissions.allow -= ["Bash(git push)"]' ~/.claude/settings.local.json.bak \
  > ~/.claude/settings.local.json

アンチパターン

  • 一括承認。 「15個すべて削除しますか? [y/n]」と尋ねるのは設計に反します。1アイテム、1判断です。
  • 初回パスでハードデリート。 _gc_trash/ コピーや .disabled リネームがない場合は、やり方を間違えています。
  • 「古い」を「死んでいる」と見なす。 60日間触れられていないスキルが季節的なもの(確定申告シーズン、四半期レビュー)である可能性があります。年数はシグナルであり、評決ではありません。だからこそ人間が確認するのです。
  • メモリを切り詰めてクリーンアップする。 矛盾する2つのメモリファイルをマージするには、両方を読み、新しい方の真実を保持する必要があります。長い方を削除するのではありません。
  • ~/.claude の外部に触れる(またはプロジェクトの .claude/)。Config GCはソースツリーに決して入り込みません。

ベストプラクティス

  • カレンダーだけでなく、大規模な追加後にも実行してください。50スキルのパックをインストールしたときこそ、既存スキルとの重複が発生するタイミングです。
  • 2つのスキルが重複している場合、トリガー説明が弱い方を無効にすることを推奨します。おそらくそもそも発動していなかったものです。
  • 権限のクリーンアップは、費やした1分あたりの価値が最も高いチャネルです。冗長な許可エントリはセキュリティレビューを困難にします。
  • gc_log.md は永久に保持してください。サイズが小さく、「そのフックをいつ無効にしたのか、なぜか」という質問は想像以上によく発生します。

関連スキル

  • skill-stocktake — スキルの品質を監査します。config-gcはスキルの存在を監査します。GCを生き延びたスキルに対してstocktakeを実行してください。
  • workspace-surface-audit — 追加的な対応物です。何をインストールすべきかを推奨します。config-gcは同じライフサイクルの減法的な半分です。
  • configure-ecc — ECCでスキルをインストールした後、config-gcを実行して既存設定との重複を調整します。
  • continuous-learning — このスキルが後で監査するメモリファイルを生成します。
  • security-review — 権限チャネルとよく組み合わせます。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

関連スキル