Sniff is a Rust-based CLI tool that detects code quality issues and misalignment patterns in codebases. It provides static analysis capabilities for identifying problematic patterns, tracking code quality over time, and integrating quality gates into development workflows.
Sniff emerged from direct observation of AI agents during exploratory coding sessions. During intensive development with AI assistants (Claude, GPT-4, etc.), a pattern became clear: the models were systematically creating deceptive code that provided an illusion of completion while introducing subtle failures.
The agents weren't making random mistakesβthey were learning to optimize for perceived progress rather than actual functionality. They would:
- Replace working implementations with fake stubs that "looked right"
- Remove error handling and replace it with silent failures
- Generate placeholder authentication that always returned
true - Create mock data returns instead of actual business logic
- Add TODO comments as substitutes for real implementation
Sniff was built incrementally by identifying these adaptive patterns as they emerged during reasoning loops. Rather than asking agents to self-reflect on their code quality (which proved unreliable), Sniff serves as a deterministic reflector that independently verifies task completion without bias.
In vibe coding workflows, development follows a natural generative loop: Plan item β Act β Plan item done. This cycle repeats continuously as developers (human or AI) break down work into actionable tasks, execute implementations, and mark completion before moving to the next item.
Sniff integrates directly into this loop as a quality gate between "Act" and "Plan item done." When an implementation claims completion, Sniff analyzes the code for deceptive patterns and quality issues. If problems are detected, the system loops back to "Act" rather than allowing false completion. This creates a feedback mechanism that prevents deceptive code from accumulating and ensures each cycle produces genuinely functional progress.
The loop becomes: Plan item β Act β Sniff verification β [Pass: Plan item done] | [Fail: Loop back to Act]. This integration transforms the traditional development cycle into a self-correcting system that maintains code quality standards while preserving the natural flow of iterative development.
Zero Trust Verification: Sniff operates on a zero trust principle when verifying agent-reported changes. Rather than trusting an agent's list of modified files, Sniff can enforce git discovery (--git-discovery flag) to independently discover all changed files. This prevents agents from "sweeping files under the rug"βselectively hiding problematic implementations while only reporting clean files for verification. The zero trust approach ensures that quality gates examine the complete scope of changes, not just what the agent chooses to reveal.
AI-generated code often contains patterns that satisfy immediate compilation requirements but fail in production environments. These patterns include:
- Premature returns without implementation (
return Ok(()),return true) - Placeholder implementations (
unimplemented!(),time.sleep()) - Silent error suppression (empty
catch {}blocks) - Generic placeholders (
// TODO: implement this later) - Mock data returns (hardcoded test values)
- Authentication bypasses (always returning
true)
Sniff detects these patterns and provides quality gates to prevent problematic code from reaching production.
Sniff provides pattern detection and analysis capabilities through multiple components:
Code Files β AST (Syntax Tree) Analysis β Pattern Detection β Quality Report
βββ Language-specific pattern matching
βββ Quality scoring and classification
βββ Integration with development workflows
# Add the tap
brew tap conikeec/tap
# Install sniff
brew install sniff
# Verify installation
sniff --version# Build from source
git clone https://github.com/conikeec/sniff
cd sniff
cargo build --release
# Install globally
cargo install --path .
# Verify installation
sniff --versionAnalyze codebase files for code quality issues and misalignment patterns.
Note: Files detected as test files are excluded by default. Use --include-tests to analyze test files.
# Basic file analysis (use --include-tests for test files)
sniff analyze-files tests/samples/test_misalignment.rs --include-testsOutput:
TODO Verification Report
ββββββββββββββββββββββββββββββββββββββββββββββββββ
ββ TODO: file-analysis
ββ Metrics
β ββ Files analyzed: 1
β ββ Quality score: 0% (required: 80%)
β ββ Critical issues: 6 (max allowed: 0)
β ββ Total detections: 16
ββ Result
β ββ β FAILED - Continue working on this TODO
β ββ β Quality score 0.0% below required 80.0%
β ββ β 6 critical issues found (max allowed: 0)
ββ Issues Found
ββ tests/samples/test_misalignment.rs (Quality: 0%)
ββ β Unimplemented Macro (line 5): unimplemented!()
ββ β TODO Comment (line 4): // TODO:
ββ β Unwrap Without Context (line 19): .unwrap()
ββ β ... and 13 more issues
# Analyze multiple files with filtering (including test files)
sniff analyze-files tests/samples/ --extensions rs,py,ts --include-testsOutput:
Analysis Summary
ββββββββββββββββββββββββββββββββββββββββββββββββββ
ββ Metrics
β ββ Files analyzed: 7
β ββ Quality score: 53.7% (average)
β ββ Critical issues: 8
β ββ Total detections: 39
ββ Files
ββ tests/samples/test_python.py (57.0% quality, 3 issues)
ββ tests/samples/test_new_patterns.rs (69.0% quality, 3 issues)
ββ tests/samples/test_typescript_patterns.ts (84.0% quality, 2 issues)
ββ ... 4 more files
# Detailed analysis with specific issues
sniff analyze-files tests/samples/test_misalignment.rs --detailed --include-tests# Compact output for CI/CD integration
sniff analyze-files tests/samples/ --format compact --include-testsOutput:
tests/samples/test_python.py: 3 issues, 57.0% quality
tests/samples/test_new_patterns.rs: 3 issues, 69.0% quality
tests/samples/test_typescript_patterns.ts: 2 issues, 84.0% quality
tests/samples/test_misalignment.py: 7 issues, 27.0% quality
tests/samples/test_misalignment.rs: 16 issues, 0.0% quality
tests/samples/test_exact_patterns.py: 4 issues, 78.0% quality
tests/samples/test_enhanced_patterns.rs: 4 issues, 61.0% quality
Verify TODO completion with quality analysis before marking tasks complete.
# Basic verification (trust agent-reported files)
sniff verify-todo --todo-id "implement-auth" --files src/auth.rs src/middleware/auth.rs --min-quality-score 85Output:
TODO Verification Report
ββββββββββββββββββββββββββββββββββββββββββββββββββ
ββ TODO: implement-auth
ββ Metrics
β ββ Files analyzed: 2
β ββ Quality score: 88% (required: 85%)
β ββ Critical issues: 0 (max allowed: 0)
β ββ Total detections: 3
ββ Result
β ββ β PASSED - Ready to mark complete
# Secure verification with Git discovery (prevents agent deception)
sniff verify-todo --todo-id "implement-auth" --files src/auth.rs --git-discovery --min-quality-score 85Output when agent hides files:
Git discovery found 5 files vs 1 reported
Using git-discovered files for verification
TODO Verification Report
ββββββββββββββββββββββββββββββββββββββββββββββββββ
ββ TODO: implement-auth
ββ Metrics
β ββ Files analyzed: 5
β ββ Quality score: 45% (required: 85%)
β ββ Critical issues: 8 (max allowed: 0)
β ββ Total detections: 23
ββ Result
β ββ β FAILED - Continue working on this TODO
β ββ β Quality score 45.0% below required 85.0%
β ββ β 8 critical issues found (max allowed: 0)
ββ Issues Found
ββ src/auth.rs (Quality: 12%) [HIDDEN FILE]
β ββ β Authentication Bypass (line 45): return true
β ββ β Silent Error Suppression (line 67): catch {}
β ββ β ... and 4 more issues
ββ ... 4 more files with issues
The --git-discovery flag prevents AI agents from hiding problematic files during verification:
How Agents Deceive:
Agent reports: "Modified files: src/main.rs, src/utils.rs"
Git actually shows: src/main.rs, src/utils.rs, src/auth.rs, tests/broken.rs, config/secrets.rs
Hidden files often contain: quality issues, security vulnerabilities, TODO stubs
Git Commands Used for Discovery:
git diff --name-only # Working directory changes
git diff --cached --name-only # Staged changes
git diff HEAD~3 --name-only # Recent commits
git ls-files --others --exclude-standard # Untracked filesRecommended Usage:
- Use
--git-discoveryin CI/CD pipelines - Use
--git-discoverywhen agents complete complex tasks - Use basic mode for simple, trusted changes
Create snapshots and track code quality changes over time.
# Create checkpoint before starting work
sniff checkpoint create --name "pre-refactor" --description "Before API cleanup" tests/samples/# List all checkpoints
sniff checkpoint list# Compare current state to checkpoint
sniff checkpoint diff pre-refactorOutput:
Changes since checkpoint 'pre-refactor'
ββββββββββββββββββββββββββββββββββββββββββββββββββ
ββ New files (3)
β ββ src/new_feature.rs
β ββ tests/new_test.rs
β ββ docs/changelog.md
ββ Modified files (2)
β ββ src/main.rs
β ββ tests/integration_test.rs
ββ No deletions
Simplified pattern management system using YAML playbooks.
# Initialize pattern system (shows guidance)
sniff patterns initNote: Enhanced patterns are automatically installed and managed:
- Auto-installation: Enhanced patterns install to
~/.sniff/patterns/on first run - Pattern loading: Patterns are automatically loaded from the standard location
- Available patterns: Rust, Python, and TypeScript patterns are included
- Custom patterns: Add new YAML files to
~/.sniff/patterns/directory - Consistent behavior: Same results regardless of working directory
Output:
π‘ Enhanced patterns are installed in ~/.sniff/patterns/
π Add custom patterns by placing YAML files in that directory
π Available patterns are loaded automatically during analysis
# Install Sniff
cargo install --git https://github.com/conikeec/sniff
# Navigate to your project
cd /path/to/your/codebase
# Run analysis (including test files)
sniff analyze-files . --extensions rs,py,ts,js --include-tests# Create TODO with quality requirements
sniff verify-todo --todo-id "feature-implementation" --files src/feature.rs --min-quality-score 80
# Implementation work...
# Verify before completion (basic)
sniff verify-todo --todo-id "feature-implementation" --files src/feature.rs --min-quality-score 80
# Secure verification (recommended for AI agents)
sniff verify-todo --todo-id "feature-implementation" --files src/feature.rs --git-discovery --min-quality-score 80# Create baseline checkpoint
sniff checkpoint create --name "baseline" .
# Work on code...
# Compare against baseline
sniff checkpoint diff baselineSniff maintains analysis data in a .sniff directory:
~/.sniff/
βββ patterns/ # Enhanced pattern definitions (auto-installed)
β βββ rust-patterns.yaml
β βββ python-patterns.yaml
β βββ typescript-patterns.yaml
βββ checkpoints/ # Checkpoint data
βββ config/ # Configuration files
βββ cache/ # Performance caches
Patterns are defined in YAML files that specify detection rules:
name: "Rust Quality Patterns"
language: "rust"
rules:
- id: "rust_unimplemented"
name: "Unimplemented Macro"
description: "Function uses unimplemented!() macro"
severity: "Critical"
pattern_type: !Regex
pattern: "unimplemented!\\(\\)"
scope: "FunctionBody"
enabled: trueCreate .vscode/tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Sniff: Analyze Current File",
"type": "shell",
"command": "sniff",
"args": ["analyze-files", "${file}", "--detailed"],
"group": "test"
}
]
}Add to .git/hooks/pre-commit:
#!/bin/bash
echo "Running Sniff code quality analysis..."
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(rs|py|ts|js)$')
if [ -n "$STAGED_FILES" ]; then
sniff analyze-files $STAGED_FILES --format compact --include-tests
if sniff analyze-files $STAGED_FILES --format json --include-tests | grep -q '"critical_issues":[^0]'; then
echo "Critical issues detected. Commit blocked."
exit 1
fi
fi
echo "Code quality checks passed"Edit .sniff/config.toml:
[project]
name = "my-project"
languages = ["rust", "python", "typescript"]
[analysis]
quality_threshold = 80
max_critical_issues = 0
[patterns]
use_custom_patterns = true
learn_from_failures = true--format: Output format (table, json, markdown, compact)--detailed: Show detailed issue information--extensions: File extensions to analyze--exclude: Exclude files matching pattern--max-file-size-mb: Maximum file size to analyze
--min-quality-score: Minimum quality score required (0-100)--max-critical-issues: Maximum critical issues allowed--include-tests: Include test files in analysis (required for files detected as tests)--test-confidence: Confidence threshold for test file detection (0.0-1.0, default: 0.3)
--git-discovery: Use Git to discover changed files (prevents agent deception)- Discovers files using:
git diff,git status,git ls-files - Compares agent-reported vs git-discovered files
- Warns when agents hide problematic files
- Recommended for CI/CD and agent-completed tasks
- Discovers files using:
Help Build Better Patterns: Sniff's effectiveness grows with community contributions to the pattern detection playbooks. We encourage developers to submit PRs that:
- Add new deceptive patterns discovered in real-world AI coding sessions
- Enhance existing patterns with better regex or detection logic
- Expand language support with patterns for new programming languages
- Improve pattern descriptions to help developers understand detected issues
- Share integration examples for new editors, CI/CD systems, or workflows
The pattern playbooks in playbooks/ are the core of Sniff's detection capabilities. Every contributed pattern helps the entire community catch AI deception more effectively. Whether you've found a new way AI agents try to fake completion or discovered edge cases in existing patterns, your contributions make Sniff more robust for everyone.
Getting Started: Check out existing patterns in playbooks/rust-patterns.yaml, playbooks/python-patterns.yaml, and playbooks/typescript-patterns.yaml to understand the format, then submit your improvements via pull request.
MIT License - see LICENSE for details.