跳到正文
Skillpedia
通用编程260k · #619

codebase-inspection

它能做什么

这项技能让你的 AI 对软件项目进行度量,例如项目规模以及所用编程语言的构成。适合希望快速了解代码库概况的开发者和管理者。

适用场景

  • ✓你询问一个项目有多少行代码的时候。
  • ✓你想了解某个代码仓库所用语言构成的时候。
  • ✓你想知道项目中代码与注释的比例的时候。

技能链接

https://github.com/NousResearch/hermes-agent/blob/main/skills/software-development/codebase-inspection/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/NousResearch/hermes-agent/blob/main/skills/software-development/codebase-inspection/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“这个仓库有多少行代码?其中大部分是用哪些语言编写的?”

每周 5 个新技能,1 分钟读完。

工作原理

如果缺少 pygount 工具,这项技能会将其安装,然后在项目文件夹上运行。它会跳过 node_modules 和构建输出等文件夹,因此统计数字不会虚高。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Codebase Inspection with pygount

Analyze repositories for lines of code, language breakdown, file counts, and code-vs-comment ratios using pygount.

When to Use

  • User asks for LOC (lines of code) count
  • User wants a language breakdown of a repo
  • User asks about codebase size or composition
  • User wants code-vs-comment ratios
  • General "how big is this repo" questions

Prerequisites

pip install --break-system-packages pygount 2>/dev/null || pip install pygount

1. Basic Summary (Most Common)

Get a full language breakdown with file counts, code lines, and comment lines:

cd /path/to/repo
pygount --format=summary \
  --folders-to-skip=".git,node_modules,venv,.venv,__pycache__,.cache,dist,build,.next,.tox,.eggs,*.egg-info" \
  .

IMPORTANT: Always use --folders-to-skip to exclude dependency/build directories, otherwise pygount will crawl them and take a very long time or hang.

2. Common Folder Exclusions

Adjust based on the project type:

# Python projects
--folders-to-skip=".git,venv,.venv,__pycache__,.cache,dist,build,.tox,.eggs,.mypy_cache"

# JavaScript/TypeScript projects
--folders-to-skip=".git,node_modules,dist,build,.next,.cache,.turbo,coverage"

# General catch-all
--folders-to-skip=".git,node_modules,venv,.venv,__pycache__,.cache,dist,build,.next,.tox,vendor,third_party"

3. Filter by Specific Language

# Only count Python files
pygount --suffix=py --format=summary .

# Only count Python and YAML
pygount --suffix=py,yaml,yml --format=summary .

4. Detailed File-by-File Output

# Default format shows per-file breakdown
pygount --folders-to-skip=".git,node_modules,venv" .

# Sort by code lines (pipe through sort)
pygount --folders-to-skip=".git,node_modules,venv" . | sort -t$'\t' -k1 -nr | head -20

5. Output Formats

# Summary table (default recommendation)
pygount --format=summary .

# JSON output for programmatic use
pygount --format=json .

# Pipe-friendly: Language, file count, code, docs, empty, string
pygount --format=summary . 2>/dev/null

6. Interpreting Results

The summary table columns:

  • Language — detected programming language
  • Files — number of files of that language
  • Code — lines of actual code (executable/declarative)
  • Comment — lines that are comments or documentation
  • % — percentage of total

Special pseudo-languages:

  • __empty__ — empty files
  • __binary__ — binary files (images, compiled, etc.)
  • __generated__ — auto-generated files (detected heuristically)
  • __duplicate__ — files with identical content
  • __unknown__ — unrecognized file types

Pitfalls

  1. Always exclude .git, node_modules, venv — without --folders-to-skip, pygount will crawl everything and may take minutes or hang on large dependency trees.
  2. Markdown shows 0 code lines — pygount classifies all Markdown content as comments, not code. This is expected behavior.
  3. JSON files show low code counts — pygount may count JSON lines conservatively. For accurate JSON line counts, use wc -l directly.
  4. Large monorepos — for very large repos, consider using --suffix to target specific languages rather than scanning everything.
常见问题

需要特殊软件吗?

需要 pygount。如果缺少,技能会用 pip 将其安装。

为什么要跳过某些文件夹?

技能说明应跳过依赖和构建文件夹,因为扫描它们可能需要很长时间。

可以只统计一种语言吗?

可以。技能包含将结果筛选为特定语言的部分。

详情

作者的原始描述

Inspect codebases w/ pygount: LOC, languages, ratios.

repo: NousResearch/hermes-agent

热度

GitHub 星标
260k
排名
#619
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能