Skip to main content

AI Defect Verification

Skylos does not try to decide whether code "looks AI-generated" or whether an LLM thinks a change is bad. The AI-defect engine checks specific failure modes that leave concrete evidence in source code, dependency metadata, installed APIs, or a git diff.

Use it when reviewing agent-authored PRs, editor-generated changes, or high-volume AI-assisted code:

skylos . --ai-defects
skylos . --diff origin/main --ai-defects --format json

Output Contract

The full-scan contract is intentionally separate from quality and security:

SurfaceValue
CLI flag--ai-defects
Policy keyai_defects_enabled
JSON bucketai_defects
Finding categoryai_defect
Generated workflow aliasesai-defects, ai_defects

This means skylos . --quality does not include AI-defect findings. Use --ai-defects directly, or use -a / --all to enable every static category.

{
"ai_defects": [
{
"rule_id": "SKY-D224",
"category": "ai_defect",
"defect_type": "api_signature_hallucination",
"message": "Installed API does not accept keyword argument 'imaginary_timeout'."
}
],
"analysis_summary": {
"ai_defects_count": 1
}
}

Category, Not Prefix

AI-defect grouping is category-based, not prefix-based.

New AI-defect-only rules use the SKY-A prefix. Some older rules keep their historical SKY-L or SKY-D IDs so existing suppressions, baselines, CI policies, and links do not break. They still report under the ai_defects bucket when their catalog category is ai_defect.

Rule IDCategoryWhy the prefix may differ
SKY-A101 to SKY-A105ai_defectNew AI-defect-only rules
SKY-L012, SKY-L023ai_defectHistorical logic-rule IDs kept for compatibility
SKY-D222, SKY-D224, SKY-D225ai_defectHistorical dependency/API IDs kept for compatibility

Method

Every AI-defect rule should answer a narrow question with evidence:

MethodEvidence Skylos UsesExample
Symbol/API existenceImport graph, installed package metadata, stubs, and known package APIsReal package called with an invented method or keyword
Dependency realityRegistry package/version responses and parsed manifestsfastapi-security-ultra==4.2.9 does not exist
Repo symbol reachabilityDefinitions, imports, decorators, and fallback AST checks@require_admin is used but never defined or imported
Diff evidenceUnified git diff for changed filesAssertion weakened, CI permission added, or CLI flag removed
Test-impact signalChanged file set from git or PR contextAuth/billing code changed with no test file changed
Contract guardrailsLocal .skylos/ai-contract.yml clauses and scoped source filesRoute handler missing a required auth decorator

The rule must be explainable from the evidence. Skylos should not block a PR because an LLM says a change is suspicious.

Current AI-Defect Rules

RuleSeverityWhat It VerifiesEvidence TypeBlocking Posture
SKY-A101MEDIUM-HIGHTest assertion weakening, exception assertion removal, skip/xfail addedDiffUsually block or require explicit review
SKY-A102LOWHigh-risk source changed with no test file changedChanged-file setWarn only
SKY-A103HIGHGitHub Actions workflow adds write permissions or privileged triggersDiffUsually block or require explicit review
SKY-A104MEDIUMPublic CLI flag removed from argparse, Click, or Typer surfaceDiffWarn or require compatibility review
SKY-A105HIGHRoute handler missing a contract-required guard decoratorContract + route ASTBlock
SKY-L012CRITICALPhantom function/security helper callRepo symbol analysisBlock
SKY-L023CRITICALPhantom security decoratorRepo symbol analysisBlock
SKY-D222CRITICALImported package does not existPackage registry reality checkBlock
SKY-D224HIGHInstalled package called with invented API or keywordInstalled package/API introspectionBlock
SKY-D225HIGHManifest pins a package version that does not existPackage registry reality checkBlock

SKY-D223 stays in security/SCA, not AI-defects, because an undeclared but real dependency is a supply-chain/deployment issue rather than a hallucinated package.

Contract-backed findings can include contract_id, contract_clause, contract_path, and contract_reason so reviewers can see which repo-specific truth was enforced. See AI Hallucination Contracts for the contract format and skylos verify --contract workflow.

Diff-Aware PR Checks

Diff-aware AI-defect rules run only when Skylos has changed-file context:

skylos . --diff origin/main --ai-defects

or when it can infer local git changes. These rules compare the current diff instead of scanning the whole repo for pre-existing style issues.

Examples:

-assert result.status == "paid"
+assert result is not None
+permissions: write-all
-parser.add_argument("--quality", action="store_true")

The diff model reduces noise: moved unchanged lines are ignored, existing broad tests and broad CI permissions are not reported unless the PR newly weakens or adds them, and high-risk source changes only warn when the changed-file set has no accompanying test file.

What Belongs Elsewhere

Not every AI-prone problem belongs in ai_defects.

ProblemBucketReason
SQL injection, XSS, SSRF, command injectiondanger / securitySecurity impact is the primary classification
Async blocking, lock inversion, thread shared state mutationqualityReliability/maintainability issue, not AI-specific evidence
Undeclared but real dependencysecurity/SCADeployment and supply-chain risk, not a fake dependency
Generic complex AI-looking codequality or review signalNot enough evidence to call an AI defect
LLM-only opinionNone by itselfNot evidence-backed

The useful product boundary is:

Evidence-backed PR verification for AI-written code, not generic AI-code judgment.