Quickstart: Bug Prediction
Scan a codebase for patterns that predict bugs before they reach production.
from workflows.bug_predict import BugPredictionWorkflow
from workflows.bug_predict_report import format_bug_predict_report
workflow = BugPredictionWorkflow()
result = workflow.execute(path="src/")
print(format_bug_predict_report(result, {"path": "src/"}))
Expected output:
Bug Prediction Report
Risk Score: 73/100 | Files: 34 | Findings: 8
HIGH (2 findings)
src/hooks/executor.py:89 dangerous_eval eval() on user input
src/plugins/loader.py:142 dangerous_eval exec() in plugin loader
MEDIUM (3 findings)
...
Steps
1. Import the workflow and report formatter
from workflows.bug_predict import BugPredictionWorkflow
from workflows.bug_predict_report import format_bug_predict_report
2. Run the workflow against a path
workflow = BugPredictionWorkflow()
result = workflow.execute(path="src/")
BugPredictionWorkflow coordinates three subagents — pattern-scanner, risk-correlator, and prevention-advisor — and returns a WorkflowResult containing a summary, grouped findings, and prevention suggestions.
3. Format and read the report
print(format_bug_predict_report(result, {"path": "src/"}))
The report groups findings by severity (HIGH, MEDIUM, LOW). Each finding includes a file path, line number, pattern type, and a plain-English description. Start with the HIGH findings — these flag patterns like eval() on user input and broad except clauses that silently swallow errors.
4. Run from the command line
If you prefer a CLI workflow, use the entry point directly:
python -m workflows.bug_predict_report
main() runs the full prediction workflow and prints the formatted report to stdout.
Next: Read How to Run Bug Prediction to learn how to filter by severity, interpret risk scores, and act on findings.
Unresolved references
Auto-generated by attune-author fact-check. Review and either fix the source code, fix this doc, or add an override.
| Location | Severity | Issue |
|---|---|---|
| Line 15 (code fence) | error | from workflows.bug_predict import … — module not importable |
| Line 15 (code fence) | error | from workflows.bug_predict_report import … — module not importable |
| Line 74 | error | [How to Run Bug Prediction](tasks/use-bug-predict.md) — target does not exist |