llm-artifacts-detection
Scannednpx machina-cli add skill existential-birds/beagle/llm-artifacts-detection --openclawFiles (1)
SKILL.md
5.3 KB
LLM Artifacts Detection
Detect and flag common patterns introduced by LLM coding agents that reduce code quality.
Detection Categories
| Category | Reference | Key Issues |
|---|---|---|
| Tests | references/tests-criteria.md | DRY violations, library testing, mock boundaries |
| Dead Code | references/dead-code-criteria.md | Unused code, TODO/FIXME, backwards compat cruft |
| Abstraction | references/abstraction-criteria.md | Over-abstraction, copy-paste drift, over-configuration |
| Style | references/style-criteria.md | Obvious comments, defensive overkill, unnecessary types |
Agent Prompts
Use these prompts to spawn focused detection agents:
Tests Agent
Analyze the test files for LLM-introduced test quality issues:
1. **DRY Violations**: Look for setup/teardown code repeated across multiple test functions instead of using fixtures or shared helpers. Flag patterns like:
- Identical object creation in multiple tests
- Repeated mock configurations
- Copy-pasted database setup
2. **Library Testing**: Identify tests that validate standard library or framework behavior rather than application code. Signs:
- No imports from the application codebase
- Testing built-in functions or third-party library methods
- Assertions about stdlib behavior
3. **Mock Boundaries**: Flag mocking that's too deep or too shallow:
- Too deep: Mocking internal implementation details, private methods
- Too shallow: Mocking at the wrong layer, missing integration points
- Wrong level: Unit test mocks in integration tests or vice versa
For each issue found, report: [FILE:LINE] ISSUE_TITLE
Dead Code Agent
Scan the codebase for dead code and cleanup opportunities:
1. **Unused Code**: Find functions, classes, and variables with no references:
- Functions never called
- Classes never instantiated
- Module-level variables never read
- Unreachable code after returns
2. **TODO/FIXME Comments**: Flag all TODO, FIXME, HACK, XXX comments that indicate incomplete work
3. **Backwards Compat Cruft**: Look for patterns suggesting removed features:
- Variables renamed with _unused, _old, _deprecated suffixes
- Re-exports only for backwards compatibility
- Comments like "# removed", "# legacy", "# deprecated"
- Empty functions/classes kept "for compatibility"
4. **Orphaned Tests**: Tests for code that no longer exists:
- Test files with no corresponding source
- Test functions testing deleted features
For each issue found, report: [FILE:LINE] ISSUE_TITLE
Abstraction Agent
Review the codebase for over-engineering introduced by LLM agents:
1. **Over-Abstraction**: Identify unnecessary abstraction layers:
- Wrapper classes that just delegate to one method
- Interfaces/protocols with only one implementation
- Abstract base classes with single concrete class
- Factory functions that always return the same type
2. **Copy-Paste Drift**: Find 3+ similar code blocks that should be parameterized:
- Nearly identical functions with minor variations
- Repeated patterns that could be a single function with parameters
- Similar class methods across multiple classes
3. **Over-Configuration**: Flag configuration for non-configurable things:
- Feature flags that are never toggled
- Environment variables always set to one value
- Config options with no production variation
- Overly generic code for single use case
For each issue found, report: [FILE:LINE] ISSUE_TITLE
Style Agent
Check for verbose LLM-style patterns that reduce code clarity:
1. **Obvious Comments**: Comments that restate what the code clearly does:
- "# increment counter" above counter += 1
- "# return the result" above return result
- Docstrings that repeat the function name
2. **Over-Documentation**: Excessive documentation on trivial code:
- Full docstrings on simple getters/setters
- Parameter descriptions for obvious args
- Return value docs for self-evident returns
3. **Defensive Overkill**: Unnecessary defensive programming:
- try/except around code that cannot fail
- Null checks on values that can't be null
- Type checks after type hints guarantee the type
- Validation of already-validated inputs
4. **Unnecessary Type Hints**: Type hints that add no value:
- Type hints on obvious literal assignments
- Redundant hints on variables immediately clear from context
- Over-annotated internal/local variables
For each issue found, report: [FILE:LINE] ISSUE_TITLE
Usage
- Load this skill when reviewing AI-generated code
- Spawn agents for specific detection categories as needed
- Use reference files for detailed criteria and examples
- Report issues in format:
[FILE:LINE] ISSUE_TITLE
When to Apply
- Cleaning up code written by AI coding agents
- Post-generation code review
- Reducing code bloat from iterative AI generation
- Identifying patterns that reduce maintainability
Source
git clone https://github.com/existential-birds/beagle/blob/main/plugins/beagle-core/skills/llm-artifacts-detection/SKILL.mdView on GitHub Overview
LLM Artifacts Detection identifies patterns commonly introduced by AI coding agents that degrade code quality. It focuses on tests quality, dead code, over-abstraction, and verbose style, helping clean up AI-generated code and review agent cruft.
How This Skill Works
The skill analyzes the codebase against defined criteria for Tests, Dead Code, Abstraction, and Style, referencing the provided guidance. It uses specialized detection agents (Tests Agent, Dead Code Agent, Abstraction Agent, Style Agent) to surface issues and reports them in a [FILE:LINE] format for targeted cleanup.
When to Use It
- During post-generation cleanup of AI-written code
- When reviewing test suites for DRY violations and mock boundaries
- To remove dead code, TODO/FIXME markers, and backwards-compat cruft
- To identify over-abstraction and copy-paste drift in code paths
- Before releasing AI-assisted projects to ensure clean style and maintainability
Quick Start
- Step 1: Run the llm-artifacts-detection skill against the repository
- Step 2: Review the [FILE:LINE] reports and verify context in the codebase
- Step 3: Refactor flagged artifacts and commit with a brief rationale
Best Practices
- Run the detector on new AI-generated modules first and validate the findings with the code context
- Cross-check reported issues against tests and CI results before changing behavior
- Tune expectations to minimize false positives (e.g., intentional placeholders or legacy patterns)
- Document each refactor with a brief rationale for removing artifacts
- Iterate: fix artifacts, re-run detection, and verify no regressions have been introduced
Example Use Cases
- Example: Detect DRY violations and repetitive mock setups in tests created by an LLM agent
- Example: Identify unused functions or dead code introduced during AI-driven development
- Example: Flag over-abstraction in wrapper classes and single-method interfaces
- Example: Remove legacy or deprecated patterns that were kept for compatibility
- Example: Clean up obvious comments and defensive overkill that reduce readability
Frequently Asked Questions
Add this skill to your agents