feat: add similarity-analysis command and enhance setup-claude.sh - #213
Conversation
- Add /similarity-analysis command using similarity-ts for code duplication detection - Update README.md with command documentation - Extend allowed-tools in config-base-sync-update.md - Enhance setup-claude.sh with commands/agents/hooks sync and improved hookify patching 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdded documentation for a code similarity analysis tool and expanded an allowed-tools list; enhanced the setup script to synchronize commands/agents/hooks from a repository, add new sync variables, and improve hookify discovery and patching (imports, shebangs, init handling, executability). Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant DevRepo as Repository (repo)
participant Setup as setup-claude.sh
participant FS as CLAUDE_DIR (filesystem)
participant Hookify as hookify tool
Note over Setup,DevRepo: Start synchronization
DevRepo->>Setup: Provide REPO_COMMANDS_DIR / REPO_AGENTS_DIR / REPO_HOOKS_DIR
Setup->>FS: Copy/sync command MD files, agents, hooks
alt important commands missing
Setup->>Setup: retry copy important commands
end
Note over Setup,Hookify: Discover hookify paths
Setup->>Hookify: search HOOKIFY_PATHS and cache
alt hookify found
Setup->>Hookify: apply patches (imports, shebangs)
Setup->>FS: ensure __init__.py, set executables
else not found
Setup-->>FS: skip patching (log informational)
end
Setup->>DevRepo: log sync summary / completion
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.claude/commands/similarity-analysis.md (1)
1-69: Add prerequisites section forsimilarity-tsinstallation.The documentation is well-structured and comprehensive. However, it assumes
similarity-tsis already installed. Consider adding a prerequisites section to guide users on installation or checking availability.🔎 Suggested addition
Add after line 15 (before "## 実行手順"):
## 前提条件 このコマンドは `similarity-ts` ツールを使用します。 ```bash # インストール確認 which similarity-ts # インストールされていない場合 npm install -g similarity-ts # または pnpm add -g similarity-ts</details> </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used**: defaults **Review profile**: CHILL **Plan**: Pro <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 63e1ca165e77e0d01306fd92ab3c8fb6a01f31ea and b7da13879a6fecbdc991e10e8fffce61394ddf90. </details> <details> <summary>📒 Files selected for processing (4)</summary> * `.claude/commands/README.md` * `.claude/commands/config-base-sync-update.md` * `.claude/commands/similarity-analysis.md` * `script/setup-claude.sh` </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🧠 Learnings (7)</summary> <details> <summary>📚 Learning: 2025-12-01T03:45:17.253Z</summary>Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml**Applied to files:** - `.claude/commands/README.md` - `script/setup-claude.sh` </details> <details> <summary>📚 Learning: 2025-12-09T08:39:14.049Z</summary>Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-09T08:39:14.049Z
Learning: Follow development quality standards defined inCLAUDE.mdwhen using Claude Code for development assistance**Applied to files:** - `.claude/commands/README.md` </details> <details> <summary>📚 Learning: 2025-12-01T03:45:17.253Z</summary>Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/ci.yml : Validate code quality in CI pipeline (.github/workflows/ci.yml) with linting, formatting, testing, and building**Applied to files:** - `.claude/commands/README.md` </details> <details> <summary>📚 Learning: 2025-12-01T03:45:17.253Z</summary>Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/docker-image.yml : Build DevContainer images automatically with semantic versioning and multi-platform support in .github/workflows/docker-image.yml**Applied to files:** - `.claude/commands/config-base-sync-update.md` </details> <details> <summary>📚 Learning: 2025-12-01T03:45:17.253Z</summary>Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Publish DevContainer images to ghcr.io/keito4/config-base with semantic versioning**Applied to files:** - `.claude/commands/config-base-sync-update.md` </details> <details> <summary>📚 Learning: 2025-12-01T03:45:17.253Z</summary>Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/update-libraries.yml : Execute npm run update:libs on schedule and open pull requests when dependencies or Codex/Claude tooling changes in .github/workflows/update-libraries.yml**Applied to files:** - `.claude/commands/config-base-sync-update.md` </details> <details> <summary>📚 Learning: 2025-12-01T03:45:17.253Z</summary>Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to {.codex/,.devcontainer/codex*,package*.json,npm/global.json} : Use Conventional Commits format with release-triggering types (feat/fix/perf/revert/docs) for commits touching .codex/, .devcontainer/codex*, package*.json, or npm/global.json**Applied to files:** - `.claude/commands/config-base-sync-update.md` </details> </details><details> <summary>🧬 Code graph analysis (1)</summary> <details> <summary>script/setup-claude.sh (1)</summary><blockquote> <details> <summary>script/lib/output.sh (3)</summary> * `log_info` (82-82) * `log_warn` (84-84) * `log_success` (83-83) </details> </blockquote></details> </details><details> <summary>🪛 GitHub Actions: CI</summary> <details> <summary>script/setup-claude.sh</summary> [warning] 111-111: SC2012: Use find instead of ls to better handle non-alphanumeric filenames. --- [warning] 124-124: SC2012: Use find instead of ls to better handle non-alphanumeric filenames. </details> </details> </details> <details> <summary>⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)</summary> * GitHub Check: claude-review </details> <details> <summary>🔇 Additional comments (6)</summary><blockquote> <details> <summary>.claude/commands/config-base-sync-update.md (1)</summary><blockquote> `3-3`: **LGTM! Expanded tooling aligns with synchronization workflows.** The addition of standard bash utilities (sed, grep, cat, echo, mkdir, rm, mv, cp, date) to the allowed-tools list is appropriate and supports the enhanced file synchronization operations introduced in `script/setup-claude.sh`. </blockquote></details> <details> <summary>script/setup-claude.sh (4)</summary><blockquote> `31-33`: **LGTM! Variable declarations follow established patterns.** The new public variables (REPO_COMMANDS_DIR, REPO_AGENTS_DIR, REPO_HOOKS_DIR) are well-named, properly quoted, and consistent with the existing REPO_PLUGINS_DIR convention. --- `52-104`: **LGTM! Robust command synchronization with comprehensive error handling.** The command synchronization logic features: - Safe file iteration using `find` with null-terminated strings - Individual file copying with error tracking (copied/failed counts) - Validation and retry logic for critical commands - Appropriate fallback messages for missing directories --- `266-282`: **LGTM! Dynamic hookify discovery with robust path validation.** The expanded hookify search logic correctly: - Initializes with known marketplace paths - Dynamically discovers hookify installations in the cache directory - Validates discovered paths before adding to the array - Uses null-terminated strings for safe path handling --- `283-349`: **LGTM! Comprehensive hookify patching with proper flag tracking.** The enhanced hookify patching logic features: - Proper tracking of discovered installations via `hookify_found` flag - Comprehensive shebang fixes for both hooks/ directory and plugin root Python files - Robust error handling with fallback for missing installations - Consistent approach across all patching operations </blockquote></details> <details> <summary>.claude/commands/README.md (1)</summary><blockquote> `3-3`: **LGTM! Documentation accurately reflects new similarity-analysis feature.** The documentation updates: - Remove the hardcoded command count for better maintainability - Add a comprehensive "Code Analysis" section describing the new similarity-analysis feature with clear usage examples and feature highlights Also applies to: 19-37 </blockquote></details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Pull Request Review - PR #213このPRは /similarity-analysis コマンドの追加と setup-claude.sh の強化を実施しています。全体的に良質な実装ですが、いくつかの改善点と懸念事項があります。 良い点
重大な懸念 - 依存関係の不足問題: similarity-ts コマンドが使用されているが、package.json に依存関係が追加されていない similarity-analysis.md:21 で similarity-ts コマンドが使用されています 影響:
推奨修正: npm install --save-dev similarity-ts 優先度: 高 - この修正がないとコマンドが機能しません その他の改善点setup-claude.sh:273-281 - パフォーマンス最適化find コマンドは既に hookify という名前のディレクトリのみを返すため、二重チェックは冗長です。条件チェックを削除することで最適化可能です。 setup-claude.sh:316-330 - コード重複shebang 修正ロジックが hooks/ ディレクトリとルートディレクトリで重複しています。共通関数に抽出することで保守性が向上します。 config-base-sync-update.md:2 - allowed-tools の過剰な追加多数の基本的な bash コマンド(特に rm:)が allowed-tools に追加されました。セキュリティリスクの観点から、必要最小限のコマンドのみを許可し、rm: は具体的なパターンに制限することを推奨します。 similarity-analysis.md - テストカバレッジ新しいコマンドに対する自動テストが見当たりません。CLAUDE.md の品質基準(70%+ カバレッジ)に準拠するため、コマンドの動作を検証する統合テストの追加を推奨します。 総合評価
マージ前に対応すべき事項必須
強く推奨
任意
結論このPRは有用な機能追加を含んでいますが、similarity-ts の依存関係追加が必須です。この修正なしではコマンドが機能しないため、マージ前に対応してください。その他の改善点は優先度に応じて対応を検討してください。全体的には良質な実装であり、上記の懸念事項が解消されれば承認可能です。 レビュー完了 - ご確認ください! 🤖 Generated with Claude Code |
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (2)
script/setup-claude.sh (2)
106-117: Successfully addresses past review feedback.The agents synchronization now uses
findinstead oflsfor file counting (line 111), resolving the ShellCheck SC2012 warning from previous review comments.
119-130: Successfully addresses past review feedback.The hooks synchronization now uses
findinstead oflsfor file counting (line 124), resolving the ShellCheck SC2012 warning from previous review comments.
🧹 Nitpick comments (1)
script/setup-claude.sh (1)
266-282: Good enhancement to hookify discovery logic.The dynamic array-based approach with cache directory search is more robust than hard-coded paths.
💡 Optional: Remove redundant path validation
Line 277's check
[[ "$cache_dir" == *"/hookify" ]]is redundant sincefind -name "hookify"already guarantees the directory name matches exactly. You can simplify:- # find -name "hookify" は正確に "hookify" という名前のディレクトリを返すので、 - # パスが "hookify" で終わることを確認するだけで十分 - if [[ -d "$cache_dir" ]] && [[ "$cache_dir" == *"/hookify" ]]; then + if [[ -d "$cache_dir" ]]; then HOOKIFY_PATHS+=("$cache_dir") fi
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
script/setup-claude.sh
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml
Applied to files:
script/setup-claude.sh
🧬 Code graph analysis (1)
script/setup-claude.sh (1)
script/lib/output.sh (3)
log_info(82-82)log_warn(84-84)log_success(83-83)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: claude-review
🔇 Additional comments (3)
script/setup-claude.sh (3)
31-35: LGTM! Clean variable declarations.The new repository path variables follow the existing naming convention and integrate well with the enhanced synchronization logic.
48-104: Excellent error handling and validation logic.The commands synchronization implementation is robust:
- Uses
findwith-print0for safe filename handling- Tracks copy success/failure granularly
- Validates important commands with retry logic
283-349: Well-structured hookify patching enhancements.The implementation correctly:
- Uses a flag to track hookify discovery and control messaging
- Extends shebang fixes to plugin root Python files
- Maintains consistency with existing hooks patching logic
- Ensures file executability
PR Review: similarity-analysis コマンドと setup-claude.sh の機能強化全体評価このPRは新しいコード類似度分析コマンド、setup-claude.shの同期機能強化、allowed-tools拡張を含む、品質の高い実装です。 コード品質良い点
改善提案Critical: エラーハンドリング改善必要 setup-claude.sh:110, 123で Critical: 一時ファイルクリーンアップ不足 setup-claude.sh:305-308で その他の推奨事項
テストカバレッジ
CLAUDE.md準拠
承認状態条件付き承認: Critical問題(cp -rエラーハンドリング、一時ファイルクリーンアップ)修正後、マージ可能です。 レビュアー: Claude Sonnet 4.5 |
|
🎉 This PR is included in version 1.25.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
/similarity-analysisコマンドを追加(similarity-tsを使用したコード重複検出)setup-claude.shにコマンド・エージェント・フックの同期機能を追加config-base-sync-update.mdの allowed-tools を拡張Changes
New:
/similarity-analysiscommandリポジトリ内のコード類似度を分析し、重複関数やパターンを検出するコマンド。
使用例:
機能:
Enhanced:
setup-claude.sh.claude/commands/,.claude/agents/,.claude/hooks/を~/.claude/に同期Updated:
config-base-sync-update.mdallowed-toolsにsed,grep,cat,echo,mkdir,rm,mv,cp,dateを追加Test plan
similarity-tsコマンドの動作確認🤖 Generated with Claude Code
Summary by CodeRabbit
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.