$npx -y skills add adityahimaone/hermes-agent-rtk-caveman --skill codebase-inspectionInspect and analyze codebases using pygount for LOC counting, language breakdown, and code-vs-comment ratios. Use when asked to check lines of code, repo size, language composition, or codebase stats.
| 1 | # Codebase Inspection with pygount |
| 2 | |
| 3 | Analyze repositories for lines of code, language breakdown, file counts, and code-vs-comment ratios using `pygount`. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - User asks for LOC (lines of code) count |
| 8 | - User wants a language breakdown of a repo |
| 9 | - User asks about codebase size or composition |
| 10 | - User wants code-vs-comment ratios |
| 11 | - General "how big is this repo" questions |
| 12 | |
| 13 | ## Prerequisites |
| 14 | |
| 15 | ```bash |
| 16 | pip install --break-system-packages pygount 2>/dev/null || pip install pygount |
| 17 | ``` |
| 18 | |
| 19 | ## 1. Basic Summary (Most Common) |
| 20 | |
| 21 | Get a full language breakdown with file counts, code lines, and comment lines: |
| 22 | |
| 23 | ```bash |
| 24 | cd /path/to/repo |
| 25 | pygount --format=summary \ |
| 26 | --folders-to-skip=".git,node_modules,venv,.venv,__pycache__,.cache,dist,build,.next,.tox,.eggs,*.egg-info" \ |
| 27 | . |
| 28 | ``` |
| 29 | |
| 30 | **IMPORTANT:** Always use `--folders-to-skip` to exclude dependency/build directories, otherwise pygount will crawl them and take a very long time or hang. |
| 31 | |
| 32 | ## 2. Common Folder Exclusions |
| 33 | |
| 34 | Adjust based on the project type: |
| 35 | |
| 36 | ```bash |
| 37 | # Python projects |
| 38 | --folders-to-skip=".git,venv,.venv,__pycache__,.cache,dist,build,.tox,.eggs,.mypy_cache" |
| 39 | |
| 40 | # JavaScript/TypeScript projects |
| 41 | --folders-to-skip=".git,node_modules,dist,build,.next,.cache,.turbo,coverage" |
| 42 | |
| 43 | # General catch-all |
| 44 | --folders-to-skip=".git,node_modules,venv,.venv,__pycache__,.cache,dist,build,.next,.tox,vendor,third_party" |
| 45 | ``` |
| 46 | |
| 47 | ## 3. Filter by Specific Language |
| 48 | |
| 49 | ```bash |
| 50 | # Only count Python files |
| 51 | pygount --suffix=py --format=summary . |
| 52 | |
| 53 | # Only count Python and YAML |
| 54 | pygount --suffix=py,yaml,yml --format=summary . |
| 55 | ``` |
| 56 | |
| 57 | ## 4. Detailed File-by-File Output |
| 58 | |
| 59 | ```bash |
| 60 | # Default format shows per-file breakdown |
| 61 | pygount --folders-to-skip=".git,node_modules,venv" . |
| 62 | |
| 63 | # Sort by code lines (pipe through sort) |
| 64 | pygount --folders-to-skip=".git,node_modules,venv" . | sort -t$'\t' -k1 -nr | head -20 |
| 65 | ``` |
| 66 | |
| 67 | ## 5. Output Formats |
| 68 | |
| 69 | ```bash |
| 70 | # Summary table (default recommendation) |
| 71 | pygount --format=summary . |
| 72 | |
| 73 | # JSON output for programmatic use |
| 74 | pygount --format=json . |
| 75 | |
| 76 | # Pipe-friendly: Language, file count, code, docs, empty, string |
| 77 | pygount --format=summary . 2>/dev/null |
| 78 | ``` |
| 79 | |
| 80 | ## 6. Interpreting Results |
| 81 | |
| 82 | The summary table columns: |
| 83 | - **Language** — detected programming language |
| 84 | - **Files** — number of files of that language |
| 85 | - **Code** — lines of actual code (executable/declarative) |
| 86 | - **Comment** — lines that are comments or documentation |
| 87 | - **%** — percentage of total |
| 88 | |
| 89 | Special pseudo-languages: |
| 90 | - `__empty__` — empty files |
| 91 | - `__binary__` — binary files (images, compiled, etc.) |
| 92 | - `__generated__` — auto-generated files (detected heuristically) |
| 93 | - `__duplicate__` — files with identical content |
| 94 | - `__unknown__` — unrecognized file types |
| 95 | |
| 96 | ## Pitfalls |
| 97 | |
| 98 | 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. |
| 99 | 2. **Markdown shows 0 code lines** — pygount classifies all Markdown content as comments, not code. This is expected behavior. |
| 100 | 3. **JSON files show low code counts** — pygount may count JSON lines conservatively. For accurate JSON line counts, use `wc -l` directly. |
| 101 | 4. **Large monorepos** — for very large repos, consider using `--suffix` to target specific languages rather than scanning everything. |