code2skill can be used as a Python package as well as a CLI.
The supported high-level API is available from code2skill.api and re-exported from the package root:
from code2skill import adapt_repository, create_scan_config, estimate, run_ci, scanThese helpers are intended for application code and automation scripts.
Run the full repository pipeline and write the normal artifact set.
Run the report-only preview path. This writes report.json but does not write Skills or state.
Run the automation-oriented path that can choose between full and incremental execution.
Adapt generated Skills into one or more target instruction-file formats under the target repository root.
Use create_scan_config(...) when you need direct control over ScanConfig before calling lower-level functions such as:
from code2skill import create_scan_config, run_ci_repository
config = create_scan_config(
repo_path="/path/to/repo",
command="ci",
mode="auto",
output_dir=".code2skill",
base_ref="origin/main",
)
result = run_ci_repository(config)create_scan_config(...) treats repo_path as the repository root.
- Relative
output_dirvalues are resolved fromrepo_path - Relative
report_path,diff_file, andpricing_filevalues are resolved fromrepo_path - Relative
source_dirvalues passed toadapt_repository(...)are resolved fromrepo_path - If
report_pathis omitted, it defaults tooutput_dir/report.json
The pipeline functions return ScanExecution, which includes:
repo_pathoutput_diroutput_filescandidate_countselected_counttotal_charsrun_modechanged_filesaffected_filesaffected_skillsgenerated_skillsreport_pathreport
The lower-level config and report dataclasses are also exported from the package root:
from code2skill import PricingConfig, RunOptions, ScanConfig, ScanExecution, ScanLimitsIncremental state is reused only when the saved snapshot belongs to the same resolved repository root. Invalid or damaged state files are treated as missing state and fall back safely.