code2skill can be used as a Python package as well as a CLI.
The Python API follows the same workflow-oriented product model as the CLI: build configuration around a repository root, run one of the repository workflows, then optionally adapt generated Skill artifacts into downstream tool formats.
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. They are the recommended product-facing API.
Run the full repository workflow and write the normal artifact bundle.
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. The package root also exports the new artifact and summary contracts used by the workflow-oriented surface:
from code2skill import (
ArtifactLayout,
CommandRunSummary,
PricingConfig,
RunOptions,
ScanConfig,
ScanExecution,
ScanLimits,
)Incremental 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.