mcpField
D
deslop

deslop

github.com/agent-sh開発1.0k90 回インストール今日更新
リポジトリ

deslop について

deslop は、コード内の不要な生成物らしき箇所を検出するメンテナー向けスキルです。確度と重大度で結果を整理し、レポートや自動修正のワークフローに対応します。

主な機能

  1. 01確度別の検出結果分類
  2. 02リポジトリ全体または変更ファイルのスキャン
  3. 03quick、normal、deep の分析
  4. 04構造化 JSON の出力
  5. 05自動修正可能な項目の識別

活用シーン

  1. 01現在のブランチの変更を確認
  2. 02デバッグ文やプレースホルダーを検出
  3. 03デッドコードや空の catch を確認
  4. 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:検出結果の集約と優先順位付け

検出結果を次の順に並べ替えます。

  1. 確信度:HIGH、MEDIUM、LOW の順
  2. 重大度:high、medium、low の順
  3. 修正の複雑さ:自動修正可能なものを手動修正より先に
フェーズ 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 の修正を適用します。

コメント