deslop について
deslop は、コード内の不要な生成物らしき箇所を検出するメンテナー向けスキルです。確度と重大度で結果を整理し、レポートや自動修正のワークフローに対応します。
主な機能
- 01確度別の検出結果分類
- 02リポジトリ全体または変更ファイルのスキャン
- 03quick、normal、deep の分析
- 04構造化 JSON の出力
- 05自動修正可能な項目の識別
活用シーン
- 01現在のブランチの変更を確認
- 02デバッグ文やプレースホルダーを検出
- 03デッドコードや空の catch を確認
- 04修正ワークフロー向けに高確度の指摘を選別
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ agent-sh/ agentsys --skill deslopインストール後、Claude Code で/deslopを入力して読み込まれたか確認します。
詳細
deslop
確信度に基づく検出結果と自動修正で、コードからAI生成の不要物を取り除きます。
引数の解析
const args = '$ARGUMENTS'.split(' ').filter(Boolean);
const mode = args.find(a => ['report', 'apply'].includes(a)) || 'report';
const scope = args.find(a => a.startsWith('--scope='))?.split('=')[1] || 'all';
const thoroughness = args.find(a => a.startsWith('--thoroughness='))?.split('=')[1] || 'normal';
入力
引数:[report|apply] [--scope=<path>|all|diff] [--thoroughness=quick|normal|deep]
- モード:
report(デフォルト)またはapply - スコープ:スキャン対象
all(デフォルト):コードベース全体diff:現在のブランチで変更されたファイルのみ<path>:特定のディレクトリまたはファイル
- 詳細度:分析の深さ(デフォルト:
normal)quick:正規表現パターンのみnormal:+複数パスのアナライザーdeep:+利用可能な場合はCLIツール(jscpd、madge)
検出パイプライン
フェーズ 1:検出スクリプトの実行
検出スクリプトは、このスキルからの相対パス ../../scripts/detect.js にあります。
検出を実行(スキルディレクトリからの相対パスを使用):
# Scripts are at plugin root: ../../scripts/ from skills/deslop/
node ../../scripts/detect.js . --thoroughness normal --compact --max 50
diff スコープの場合(変更されたファイルのみ):
BASE=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@' || echo "main")
# Use newline-separated list to safely handle filenames with special chars
git diff --name-only origin/${BASE}..HEAD | \
xargs -d '\n' node ../../scripts/detect.js --thoroughness normal --compact
注:相対パス ../../scripts/detect.js は skills/deslop/ から上位のプラグインルートに移動し、そこにある scripts/ を参照します。
フェーズ 2:Repo-Map による拡張(任意)
repo-map が存在する場合は、AST ベースの分析で検出を拡張します。
// Use relative path from skill directory to plugin lib
// Path: skills/deslop/ -> ../../lib/repo-map
const repoMap = require('../../lib/repo-map');
if (repoMap.exists(basePath)) {
const map = repoMap.load(basePath);
const usageIndex = repoMap.buildUsageIndex(map);
// Find orphaned infrastructure with HIGH certainty
const orphaned = repoMap.findOrphanedInfrastructure(map, usageIndex);
for (const item of orphaned) {
findings.push({
file: item.file,
line: item.line,
pattern: 'orphaned-infrastructure',
message: `${item.name} (${item.type}) is never used`,
certainty: 'HIGH',
severity: 'high',
autoFix: false
});
}
// Find unused exports
const unusedExports = repoMap.findUnusedExports(map, usageIndex);
for (const item of unusedExports) {
findings.push({
file: item.file,
line: item.line,
pattern: 'unused-export',
message: `Export '${item.name}' is never imported`,
certainty: item.certainty,
severity: 'medium',
autoFix: false
});
}
}
フェーズ 3:検出結果の集約と優先順位付け
検出結果を次の順に並べ替えます。
- 確信度:HIGH、MEDIUM、LOW の順
- 重大度:high、medium、low の順
- 修正の複雑さ:自動修正可能なものを手動修正より先に
フェーズ 4:構造化された結果の返却
スキルは構造化された JSON を返します。修正は適用しません(オーケストレーターが処理します)。
出力形式
マーカーで囲まれた JSON 構造:
=== DESLOP_RESULT ===
{
"mode": "report|apply",
"scope": "all|diff|path",
"filesScanned": N,
"findings": [
{
"file": "src/api.js",
"line": 42,
"pattern": "debug-statement",
"message": "console.log found",
"certainty": "HIGH",
"severity": "medium",
"autoFix": true,
"fixType": "remove-line"
}
],
"fixes": [
{
"file": "src/api.js",
"line": 42,
"fixType": "remove-line",
"pattern": "debug-statement"
}
],
"summary": {
"high": N,
"medium": N,
"low": N,
"autoFixable": N
}
}
=== END_RESULT ===
確信度レベル
| レベル | 意味 | アクション |
|---|---|---|
| HIGH | 不要物であることが明らかで、自動修正しても安全です | simple-fixer で自動修正 |
| MEDIUM | 不要物である可能性が高く、確認が必要です | まずレビュー |
| LOW | 不要物の可能性がありますが、文脈によります | フラグのみ |
パターンのカテゴリ
確信度 HIGH(自動修正可能)
debug-statement:console.log、console.debug、print、println!debug-import:未使用のデバッグ/ロギング用インポートplaceholder-text:「Lorem ipsum」、「TODO: implement」empty-catch:コメントのない空の catch ブロックtrailing-whitespace:行末の空白mixed-indentation:タブとスペースの混在
確信度 MEDIUM(レビューが必要)
excessive-comments:コメントとコードの比率が 2:1 を超えるdoc-code-ratio:JSDoc が関数本体の 3 倍を超えるstub-function:プレースホルダー値のみを返すdead-code:return/throw の後に到達不能なコードがあるinfrastructure-without-impl:DB クライアントを作成しているが、使用していない
確信度 LOW(フラグのみ)
over-engineering:ファイル数とエクスポート数の比率が 20 倍を超えるbuzzword-inflation:根拠のない主張shotgun-surgery:ファイルが頻繁に同時変更される
修正の種類
| 修正の種類 | アクション | パターン |
|---|---|---|
remove-line | 行を削除 | debug-statement、debug-import |
add-comment | 説明を追加 | empty-catch |
remove-block | コードブロックを削除 | TODO を含む stub-function |
エラー処理
- Git を利用できない場合:Git に依存するチェックをスキップ
- 無効なスコープ:JSON でエラーを返す
- 解析エラー:ファイルをスキップしてスキャンを続行
統合
このスキルは次から呼び出されます。
/deslopコマンド用のdeslop-agent/next-taskのフェーズ 8(レビュー前のゲート)でscope=diffを指定
オーケストレーターは simple-fixer を起動して、確信度 HIGH の修正を適用します。
コメント
Markdown 対応