analyze

analyze is a command for coding agents from xiaobei930/cc-best. It costs 15 tokens per session (2,390 once invoked), scanned A, original, MIT.

A command that examines a codebase’s Git history and file structure to find coding patterns and team habits, then records them as reusable documentation.

In plain words
What is it for?
Use it to review commit styles, files that usually change together, folder organization, and naming conventions. It can analyze the whole project or a selected area and write results to a chosen folder.
Why use it?
It turns knowledge hidden in past changes and project structure into written guidance, so developers do not have to reconstruct team practices manually.

Command

Part of the cc-best plugin — 3 skills, 44 commands, 8 agents, 20 hooks shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/xiaobei930/cc-best/analyze
Clone the repo
git clone --depth 1 https://github.com/xiaobei930/cc-best

Or install cc-best, the plugin that ships this one along with the rest of its 3 skills, 44 commands, 8 agents, 20 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for analyze

README.md
[![agentmods](https://agentmods.dev/badge/commands/xiaobei930/cc-best/analyze.svg)](https://agentmods.dev/commands/xiaobei930/cc-best/analyze)
Your own site
<a href="https://agentmods.dev/commands/xiaobei930/cc-best/analyze"><img src="https://agentmods.dev/badge/commands/xiaobei930/cc-best/analyze.svg" alt="Measured on agentmods" height="20"></a>
Per session 15 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,390 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00015 $0.02390
Opus 5 $0.00008 $0.01195
Sonnet 5 $0.00003 $0.00478
Haiku 4.5 $0.00002 $0.00239

Measured 3d ago against content hash 8c13a967b6d6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

analyze scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/analyze.md · 339 lines

How it starts

The opening of the file, as written. The whole thing — 339 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/analyze - 代码库分析

分析项目的 Git 历史和代码结构,提取编码模式和团队实践,生成可复用的知识文档。

用法

/cc-best:analyze                    # 分析当前代码库
/cc-best:analyze --commits 100      # 分析最近 100 次提交
/cc-best:analyze --output ./docs    # 指定输出目录
/cc-best:analyze --domain api       # 仅分析特定领域

角色定位

  • 身份: 代码考古学家
  • 目标: 从历史中发现隐藏的团队智慧
  • 原则: 让沉淀的经验浮出水面

核心理念

代码库是团队智慧的结晶,Git 历史是团队习惯的日记


分析维度

1. 提交模式分析

# 获取提交消息模式
git log --oneline -n 200 | cut -d' ' -f2- | head -50

# 检测提交前缀
git log --oneline -n 200 | grep -oE "^[a-f0-9]+ (feat|fix|chore|docs|test|refactor):" | cut -d' ' -f2 | sort | uniq -c

检测目标:

  • Conventional Commits 使用率
  • 提交粒度(大提交 vs 小提交)
  • 提交消息语言(中文/英文)

2. 文件共变分析

# 找出经常一起修改的文件
git log --oneline -n 200 --name-only --pretty=format:"" |
  grep -v "^$" | sort | uniq -c | sort -rn | head -20

检测目标:

  • 架构层关联(修改 API 时总是修改 types)
  • 测试覆盖习惯(修改源码时是否修改测试)
  • 文档同步习惯

3. 目录结构分析

检测项目架构风格:
├─ 按功能划分 (feature-based)
│  └─ src/features/auth/, src/features/user/
├─ 按层次划分 (layer-based)
│  └─ src/components/, src/services/, src/utils/
└─ 混合模式 (hybrid)

4. 命名约定分析

# 检测文件命名风格
find src -name "*.ts" -o -name "*.tsx" | xargs basename -a | sort | uniq

# 检测函数命名风格
grep -rE "^(export )?(async )?function [a-zA-Z]+" src/ --include="*.ts"

检测目标:

  • 文件命名:PascalCase / camelCase / kebab-case
  • 函数命名:动词前缀风格
  • 常量命名:UPPER_SNAKE_CASE

5. 依赖使用分析

# 检测常用导入
grep -rh "^import" src/ | sort | uniq -c | sort -rn | head -20

检测目标:

  • 首选的工具库(date-fns vs moment)
  • 状态管理方案(Pinia vs Vuex vs Redux)
  • HTTP 客户端(axios vs fetch)

工作流程

1. 环境检查
   ├─ 确认是 Git 仓库
   ├─ 检查提交数量
   └─ 确定分析范围

2. 数据收集
   ├─ 提取 Git 历史
   ├─ 扫描目录结构
   ├─ 分析代码模式
   └─ 统计使用频率

3. 模式识别
   ├─ 识别提交约定
   ├─ 识别架构模式
   ├─ 识别命名规范
   └─ 识别工作流程

4. 知识生成
   ├─ 生成 SKILL.md(技能文档)
   ├─ 生成规则建议
   └─ 输出置信度评估

5. 整合建议
   ├─ 建议更新 CLAUDE.md
   ├─ 建议创建 rules/*.md
   └─ 建议添加 hooks

输出格式

分析报告

# 代码库分析报告

**分析日期**: 2026-01-27
**分析范围**: 最近 200 次提交
**代码库**: my-project

---

## 提交约定

| 模式                 | 使用率 | 置信度         |
| -------------------- | ------ | -------------- |
| Conventional Commits | 87%    | ████████░░ 85% |
| 中文提交消息         | 65%    | ██████░░░░ 60% |

**建议**: 统一使用 Conventional Commits,消息使用中文描述

---

## 架构模式

检测到: **按功能划分 (feature-based)**

Read the full file on GitHub · 339 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 339 lines · 15 tokens per session scan A 8c13a967b6d6

Subscribe to this mod's changes

analyze is a command published in the GitHub repository xiaobei930/cc-best (50 stars, last pushed 2mo ago), licensed MIT. It adds 15 tokens to every session and 2,390 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.