gen-requirements
Auto-generates clean, categorized requirements.txt and PEP 621 pyproject.toml by scanning Python codebase imports via AST. Resolves PyPI package names and installed versions.
SKILL.mdskills/storage/my_skills/gen-requirements/SKILL.md
GitHubRequirements & Dependency Generator
"One command. Zero manual dependency hunting."
Auto-generates clean, categorized requirements.txt and PEP 621-compliant pyproject.toml files by analyzing Python codebase imports using Abstract Syntax Trees (AST).
When to Use
Activate this skill when:
- Creating or updating
requirements.txtfor a Python project - Generating PEP 621
pyproject.tomlwith dependencies and dev-dependencies - Scanning a codebase to identify missing or used third-party packages
- Preparing a project for production deployment or distribution
How to Use
Via human-skills CLI
1. Standard Generation (Minimum Constraints >=X.Y.0)
human-skills '{
"tool_name": "gen_requirements",
"tool_args": {
"path": "/path/to/your/project"
}
}'
2. Exact Pinned Versions (==X.Y.Z)
human-skills '{
"tool_name": "gen_requirements",
"tool_args": {
"path": "/path/to/your/project",
"exact": "true"
}
}'
3. Custom Output Directory and Project Name
human-skills '{
"tool_name": "gen_requirements",
"tool_args": {
"path": "/path/to/your/project",
"name": "my-awesome-app",
"output_dir": "/path/to/your/project"
}
}'
4. Specific Output Format
# Only requirements.txt
human-skills '{
"tool_name": "gen_requirements",
"tool_args": {
"path": "/path/to/your/project",
"format": "requirements"
}
}'
# Only pyproject.toml
human-skills '{
"tool_name": "gen_requirements",
"tool_args": {
"path": "/path/to/your/project",
"format": "pyproject"
}
}'
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
path |
string | No | . |
Target Python project root directory to scan. |
exact |
string | No | "false" |
Use exact pinned versions (==X.Y.Z) if "true", otherwise >=X.Y.0. |
name |
string | No | Dir name | Project name written in pyproject.toml. |
output_dir |
string | No | path |
Output directory where files will be created. |
format |
string | No | "both" |
Output format: "both", "requirements", or "pyproject". |
ignored_dirs |
string | No | "" |
Additional comma-separated directories to ignore during scan (e.g. 'tests,docs,demo'). |
only_installed |
string | No | "true" |
When "true", filters out unverified/custom modules with no installed package version. When "false", includes unversioned packages. |
Key Features
- Target Virtualenv Resolution: Automatically locates project-specific virtual environments (
.venv/,venv/,env/) and queries installed package versions directly via subprocesspip list, eliminating host environment pollution. - Double-Verification & Custom Module Defense: Resolves exact installed versions from environment metadata (
importlib.metadataand project venv). Any imported module that lacks installed distribution metadata is identified as a local/custom script or phantom import and excluded by default (only_installed="true"). - AST-Powered Inspection: Parses abstract syntax trees without executing untrusted code.
- Full
src/& Local Module Discovery: Recursively detects root packages,src/,app/, andlib/modules so local code is never misidentified as a third-party dependency. - Namespace Package Support: Accurately extracts and maps namespace packages like
google.generativeai(google-generativeai),azure.storage(azure-storage-blob), etc. - Universal & Clean Ignores: Only ignores true build/VCS artifacts by default (
.git,.venv,__pycache__,node_modules, etc.), while honoring.gitignoreand allowing custom ignore overrides. - Standard Library Filtering: Automatically ignores all Python standard library modules (
os,sys,json,asyncio,pathlib, etc.). - Extended PyPI Distribution Mapping: Maps non-trivial import names (
cv2→opencv-python,PIL→pillow,pydantic_settings→pydantic-settings,attr→attrs,markdown_it→markdown-it-py). - Functional Categorization: Groups packages in
requirements.txtby role (Core Math, Web/Networking, AI/Deep Learning, Configuration, Testing, etc.). - PEP 621 Standard: Outputs standard
pyproject.tomlwith separatedependenciesand[project.optional-dependencies] dev. - Clear Failure Reporting: Reports unparseable files, virtual environment status, and uninstalled packages without silent suppression.