PyCodar
Understand your Python codebase. ๐ก Summarizes your directory in a single table. Displays the file structure of all the files, their functions, classes, and methods in a nicely colored tree. Shows a table of all the files with counts of the lines and much more.
Install / Use
/learn @QuentinWach/PyCodarREADME
PyCodar: A Radar for Your Code
A simple tool for auditing and understanding your (python) codebase.
pip install pycodar
pycodar stats: Summarizes the most basic stats of your directory in a single table. ๐pycodar strct: Displays the file structure of all the files, their functions, classes, and methods in a nicely colored tree. ๐๏ธpycodar files: Shows a table of all the files with counts of the lines of code, comments, empty lines, total lines, and file size. ๐pycodar calls: Counts how often elements (modules, functions, methods) of your code are called within the code. ๐pycodar dead: Finds (likely) unused code. โ ๏ธ
General Overview
Type
pycodar stats
in your terminal to get the most basic statistics of your directory printed out:
๐ Basic Metrics
โญโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโฎ
โ Total Size โ 54.21KB โ
โ Total Files โ 6 โ
โ Total Directories โ 2 โ
โ Total Lines โ 1,394 โ
โ Code Lines โ 885 โ
โ Comment Lines โ 26 โ
โ Empty Lines โ 208 โ
โ Functions โ 38 โ
โ Classes โ 2 โ
โฐโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโฏ
Structure
pycodar strct
gives you something like:
๐ณ File Structure
๐ Root
โโโ ๐ README.md
โโโ ๐ pyproject.toml
โโโ ๐ setup.py
โโโ ๐ pycodar
โโโ ๐ __init__.py
โโโ ๐ analyze.py
โ โโโ ๐ท CodeElementVisitor
โ โ โโโ ๐น __init__
โ โ โโโ ๐น visit_FunctionDef
โ โ โโโ ๐น visit_ClassDef
โ โ โโโ ๐น visit_Import
โ โ โโโ ๐น visit_ImportFrom
โ โ โโโ ๐น visit_Call
โ โ โโโ ๐น visit_Assign
โ โ โโโ ๐น visit_Name
โ โ โโโ ๐น visit_Attribute
โ โ โโโ ๐น visit_Return
โ โ โโโ ๐น visit_Decorator
โ โโโ ๐ธ count_functions_and_classes
โ โโโ ๐ธ get_file_size_kb
โ โโโ ๐ธ count_lines
โ โโโ ๐ธ analyze_code_connections
โ โโโ ๐ธ analyze_directory
โ โโโ ๐ธ generate_report
โโโ ๐ cli.py
โโโ ๐ท TestClass
โ โโโ ๐น __init__
โ โโโ ๐น test_method
โโโ ๐ธ extract_code_structure
โโโ ๐ธ create_structure_tree
โโโ ๐ธ parse_ignore_file
โโโ ๐ธ should_ignore
โโโ ๐ธ get_ignore_patterns
โโโ ๐ธ format_size
โโโ ๐ธ count_code_metrics
โโโ ๐ธ create_metrics_table
โโโ ๐ธ create_code_connections_table
โโโ ๐ธ create_dead_code_table
โโโ ๐ธ create_code_connections_tree
โโโ ๐ธ create_file_table
โโโ ๐ธ print_stats
โโโ ๐ธ print_structure
โโโ ๐ธ print_files
โโโ ๐ธ print_calls
โโโ ๐ธ print_dead_code
โโโ ๐ธ process_directory
โโโ ๐ธ main
File Statistics
Typing
pycodar files
will give you an overview of the lines of code, comments, empty lines, total lines and file sizes:
๐ File Distribution
โญโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโโโโฎ
โ Path โ File โ Code โ Comments โ Empty โ Total โ Size โ
โโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโค
โ Root โ pyproject.toml โ 0 โ 0 โ 0 โ 43 โ 1.37KB โ
โ Root โ README.md โ 0 โ 0 โ 0 โ 95 โ 3.37KB โ
โ Root โ setup.py โ 45 โ 0 โ 1 โ 46 โ 1.72KB โ
โ pycodar โ __init__.py โ 7 โ 1 โ 3 โ 11 โ 0.22KB โ
โ pycodar โ cli.py โ 384 โ 18 โ 90 โ 492 โ 18.62KB โ
โ pycodar โ analyze.py โ 449 โ 7 โ 114 โ 570 โ 22.27KB โ
โฐโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโโโโฏ
Calls
To check how much the modules, functions and methods in your code are actually being used, type:
pycondar calls
which will give you another table like:
๐ Most Called Elements
โญโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฎ
โ Type โ Name โ Called โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโค
โ Function โ isinstance โ 28 โ
โ Function โ print โ 22 โ
โ Function โ defaultdict โ 17 โ
โ Function โ set โ 11 โ
โ Function โ sorted โ 10 โ
โ Function โ len โ 10 โ
โ Function โ str โ 9 โ
โ Function โ open โ 7 โ
โ Function โ Path โ 4 โ
โ Function โ sum โ 4 โ
โ Method โ console.print โ 22 โ
โ Method โ table.add_row โ 15 โ
โ Method โ table.add_column โ 14 โ
โ Method โ self.generic_visit โ 8 โ
โ Method โ ast.walk โ 5 โ
โ Method โ subparsers.add_parser โ 5 โ
โ Method โ ast.parse โ 4 โ
โ Method โ tree.add โ 4 โ
โ Method โ method.startswith โ 4 โ
โ Method โ file.read โ 3 โ
โฐโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโฏ
Dead Code
And finally, to see if there is any code that's not even used, type
๐ Potentially Unused Code
โญโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Type โ Name โ
โโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Class โ pycodar.cli.TestClass โ
โฐโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
which will point you at whatever code seems to be unused.
If you need any help / a quick reminder, type:
pycodar help
and if you just want to see everything all at once, type:
pycodar all
Thank you and enjoy! ๐
Related Skills
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.8kQQBot ๅฏๅชไฝๆถๅ่ฝๅใไฝฟ็จ <qqmedia> ๆ ็ญพ๏ผ็ณป็ปๆ นๆฎๆไปถๆฉๅฑๅ่ชๅจ่ฏๅซ็ฑปๅ๏ผๅพ็/่ฏญ้ณ/่ง้ข/ๆไปถ๏ผใ
