From predicate
Applies a 4-layer adversarial audit framework to AI-generated code, detecting inefficiencies, logical flaws, and hallucinations. Activates on /ai-audit or code audit requests.
How this skill is triggered — by the user, by Claude, or both
Slash command
/predicate:ai-auditThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Verification Dual — adversarial path.** This skill is the applied methodology for the adversarial half of the [Verification Dual](../../rules.md#2-prime-invariants): when no deterministic evaluator can be built for a condition in LLM-generated code, it is closed by decorrelated, context-free agents running this audit protocol from independent attractor basins. Load it whenever the symbolic pa...
Verification Dual — adversarial path. This skill is the applied methodology for the adversarial half of the Verification Dual: when no deterministic evaluator can be built for a condition in LLM-generated code, it is closed by decorrelated, context-free agents running this audit protocol from independent attractor basins. Load it whenever the symbolic path is unavailable and an adversarial review of AI-generated code is required.
A 4-layer framework for auditing LLM-generated code. Traditional SAST is insufficient—AI code is syntactically flawless but often logically "hollow."
Principle of Zero Trust: Treat every AI-generated line as a high-risk external contribution.
LLMs prioritize token sequence probability over algorithmic optimization, creating systematic inefficiencies.
Research shows 0.74 correlation between General Logic failures and Readability/Maintainability issues.
| Category | Technical Trigger | The AI-ism | Remediation |
|---|---|---|---|
| Algorithm | Prime divisibility iterates to n instead of √n | Inefficient iterative blocks; overly broad loop conditions | Narrow loop constraints; implement early stopping |
| Algorithm | O(n²) logic where O(n log n) is standard | Sub-optimal complexity; prioritizes "plausible" over optimal | Replace with standard library or optimized algorithms |
| Assignment | Used-before-assignment; shadowing built-ins (dict = {}) | Shadowing & bloat; misuse of variable binding | Rename shadowed variables; ensure proper initialization |
| Interface | Accessing _internal members outside class scope | Structural incoherence; poor class hierarchy integration | Enforce encapsulation; refactor to public APIs |
| Checking | Passes happy path but lacks try/except or null checks | Partially wrong logic; failure to address edge cases (CWE-754) | Mandate input validation and exception traceability |
| Maintainability | Unnecessary else after return or break | Defensive bloat; complex control flow without value | Flatten conditional logic; reduce cyclomatic complexity |
AI code is logically simpler and more repetitive than human code. Any deviation into complexity without clear performance gain is a diagnostic marker of model failure.
"Slopsquatting" is a supply chain attack where adversaries register hallucinated package names.
Risk Statistics:
- GPT-4 hallucinates packages ~20% of the time
- Gemini reaches 64.5%
- The "huggingface-cli" phantom received 30,000 downloads despite being empty
pandas==2.5.0, tensorflow==3.2.1)@utils/helper in Python)If a phantom dependency is detected: Nuke and rebuild. Do not attempt to fix the import. Re-generate using only organization-approved, security-vetted libraries.
AI code exhibits "Verbosity Drift" and a specific rhythm. These stylistic markers often correlate with logic gaps.
# increment x by 1) rather than whyStop and Restart Threshold: If code complexity (NLOC/CCN) increases over 3 iterations without resolving the primary defect, discard the session. The model has entered a hallucination loop—start fresh.
The "Curse of Instructions": failure rates increase exponentially with multiple constraints. Chain-of-Thought (CoT) reasoning can divert focus from simple constraints.
Constraint Mapping: Identify all negative constraints from the original prompt
requests library"Attention Analysis: Audit the reasoning trace
High Adherence Failure: If significant violations occur under high-constraint prompts, bypass LLM's internal CoT. Use an external constraint-validation classifier.
| Layer | ODC Mapping | Focus Area | High-Risk Indicator |
|---|---|---|---|
| Layer 1 | Algorithm/Assignment | Logic & Performance | O(n²) complexity; benchmark failures |
| Layer 2 | Interface | Security & Dependencies | Hallucinated packages (20%+ risk); phantom versions |
| Layer 3 | Function/Class | Stylistic Signature | Robotic comments; defensive bloat hiding shallow logic |
| Layer 4 | Checking | Instruction Adherence | Negative constraint violations; CoT-driven neglect |
AUDIT REPORT: [Component Name]
Date: YYYY-MM-DD
Auditor: [Name]
LAYER 1: Logic & Performance
Status: [PASS/FAIL]
Findings: ...
Remediation: ...
LAYER 2: Dependencies
Status: [PASS/FAIL]
Findings: ...
Remediation: ...
LAYER 3: Stylistic Signature
Status: [PASS/FAIL]
Findings: ...
Remediation: ...
LAYER 4: Instruction Adherence
Status: [PASS/FAIL]
Findings: ...
Remediation: ...
OVERALL: [PASS/FAIL/CONDITIONAL]
Priority Remediations:
1. ...
2. ...
Present report to Software Architect prioritizing remediability. High-risk artifacts must be rejected immediately. Highlight where code lacks "lexical diversity" or "structural depth" and provide ODC-mapped remediation steps.
npx claudepluginhub nrdxp/predicate --plugin predicateAudits AI-generated or rapidly prototyped code for structural flaws, fragility, and production risks. Identifies hidden technical debt and architectural weaknesses.
Runs adversarial multi-agent code audits with challenge/verify pipeline. Use for deep quality reviews, not quick PR screening (use /preview for that).
Conducts interactive audits of AI-generated or legacy codebases to identify technical debt, anti-patterns, quality issues, and modernization opportunities.