Skip to content

voidborne-d/sober-coding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸงŠ Sober Coding

The hangover cure for vibe coding. Analyze AI-generated code quality, locate technical debt, and get actionable fixes.

GitHub stars License: MIT Language-Agnostic Claude Code

ไธญๆ–‡ๆ–‡ๆกฃ


Philosophy

Vibe coding is fast. Sober coding keeps it alive.

We're not against vibe coding. AI-generated code is the future.

But vibe coding has a fatal flaw: it creates technical debt 10x faster than humans.

Traditional tools (ESLint, SonarQube) catch human coding mistakes. AI-generated code has its own "smell" โ€” duplication patterns, over-generation, missing edge cases, structural redundancy.

Sober Coding specifically targets these AI-native patterns, helping you clean up before technical debt spirals out of control.


The Problem

You vibe-coded a project with Cursor, Claude Code, or Copilot. It runs. But deep down, you know:

  • ๐Ÿ”ด Dead code everywhere โ€” AI generated 5 versions, you kept the last one, the other 4 are still there
  • ๐Ÿ”ด Copy-paste hell โ€” Same logic appears 3 times because AI rewrote it from scratch each time
  • ๐Ÿ”ด No error handling โ€” Happy path is perfect, anything else crashes
  • ๐Ÿ”ด God files โ€” 2000-line utils.py that does everything
  • ๐Ÿ”ด Dependency chaos โ€” 47 packages installed, 12 actually used
  • ๐Ÿ”ด Security holes โ€” Hardcoded secrets, SQL injection, path traversal
  • ๐Ÿ”ด Zero tests โ€” "It works on my machine" is the only test

Sober Coding finds all of this, tells you what to fix first, and how.


Real-World Demo

Scanning a real vibe-coded full-stack project (Python + Vue.js, 50 files, 13k lines):

sober scan ./RedInk
๐ŸงŠ Sober Coding v0.1.0 โ€” Let's see what we're working with.

Scanning ./RedInk (50 files, 13,579 lines)

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚  SOBRIETY SCORE: 0/100  ๐Ÿ”ด BLACKOUT  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

  ๐ŸŸ  High (fix this week)
     ERR-001  Empty except block in backend/routes/config_routes.py:231
     ERR-001  Empty except block in backend/services/content.py:111
     ERR-001  Empty catch block in frontend/src/views/HistoryView.vue:189
     ... (7 total)

  ๐ŸŸก Medium (fix this sprint)
     ARC-004  Deep nesting in backend/app.py:89
     DED-004  Unreachable code in backend/generators/google_genai.py:372
     DUP-001  Exact duplicate code block in backend/generators/image_api.py:68
     ARC-001  God file: backend/generators/google_genai.py (500+ lines)
     ERR-002  No error handling in backend/services/content.py:45
     ... (1,067 total)

  โšช Low (when you can)
     DUP-003  Structural clone detected in backend/generators/image_api.py:51
     DED-002  Unused import: Dict in backend/app.py:2
     ... (94 total)

  ๐Ÿ’Š Run `sober fix ERR-001` to get fix instructions

1,172 issues found. The top offenders:

Issue Count What it means
ARC-004 604 Deep nesting (>4 levels) โ€” AI loves nested if/for/try
DED-004 226 Unreachable code after return/break
DUP-001 180 Exact duplicate code blocks across files
DUP-003 81 Same control-flow structure, different variable names
ERR-002 30 Async calls without error handling

This is what vibe coding looks like under the hood.


Fix Mode

Doesn't just point out problems โ€” tells you how to fix them:

sober fix DUP-012
๐Ÿ”ง DUP-012: Near-duplicate code detected (89% similarity)

  File A: utils/parse.py:45-92
  File B: helpers/format.py:12-58

  WHY IT MATTERS:
  Fix a bug in one, the other still has it. AI didn't know it already wrote this.

  HOW TO FIX:
  1. Extract shared logic into a single function
  2. Both files import from the shared module
  3. Delete the duplicate

  SUGGESTED REFACTOR:
  โ”Œโ”€ shared/text_utils.py (new) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚ def normalize_text(raw: str) -> str:          โ”‚
  โ”‚     """Merge of parse.py:45-92 & format.py""" โ”‚
  โ”‚     ...                                        โ”‚
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

  AUTO-FIX AVAILABLE: sober fix DUP-012 --apply

Install

# npm (recommended)
npm install -g sober-coding

# pip
pip install sober-coding

# From source
git clone https://github.com/voidborne-d/sober-coding.git
cd sober-coding && npm link

# Claude Code Skill
npx skills add https://github.com/voidborne-d/sober-coding.git

# ClawHub
clawhub install sober-coding

Zero config. Zero API keys. Runs 100% locally.


Claude Code

Copy slash commands into your project:

cp sober-coding/claude-code/*.md YOUR_PROJECT/.claude/commands/

Then use directly:

/sober-scan              # Full project scan
/sober-fix DUP-012       # Get fix instructions
/sober-report            # Generate HTML report
/sober-watch             # Watch mode โ€” scan on every save

What It Checks

๐Ÿ”’ Security

ID Check Description
SEC-001 Hardcoded secrets API keys, passwords, tokens in source code
SEC-002 SQL injection String concatenation in SQL queries
SEC-003 Path traversal User input directly in file paths
SEC-004 Insecure dependencies Known vulnerable dependency versions
SEC-005 CORS misconfiguration Access-Control-Allow-Origin: *

๐Ÿ—๏ธ Architecture

ID Check Description
ARC-001 God files Single file exceeding 500 lines
ARC-002 Circular dependencies Circular imports between modules
ARC-003 Mixed concerns API + DB + business logic in one file
ARC-004 Deep nesting More than 4 levels of indentation
ARC-005 Spaghetti imports Import graph entropy

๐Ÿ”„ Duplication

ID Check Description
DUP-001 Exact clones Identical code blocks
DUP-002 Near clones High similarity (>70%), classic AI behavior
DUP-003 Structural clones Same structure, different variable names

โš ๏ธ Error Handling

ID Check Description
ERR-001 Empty catch blocks catch (e) {} swallowing all errors
ERR-002 No error handling Async calls without try-catch
ERR-003 Generic catches Single top-level catch for everything
ERR-004 Missing input validation User input without validation

๐Ÿ“ฆ Dependencies

ID Check Description
DEP-001 Unused dependencies Listed in manifest but never imported
DEP-002 Duplicate functionality lodash AND underscore installed
DEP-003 Outdated versions Major dependencies 2+ versions behind

๐Ÿงช Testing

ID Check Description
TST-001 No tests Zero test files found
TST-002 Low coverage Test coverage below threshold
TST-003 No edge cases Only happy path tested

๐Ÿ’€ Dead Code

ID Check Description
DED-001 Unused functions Defined but never called
DED-002 Unused imports Imported but never used
DED-003 Commented-out code Large blocks of commented code
DED-004 Unreachable code Code after return/break

Scoring

Score Level Meaning
80-100 ๐ŸŸข SOBER Clean, maintainable code. Ship it.
60-79 ๐ŸŸก TIPSY Some issues. Fix before it gets worse.
40-59 ๐ŸŸ  HUNGOVER Significant debt. Needs a cleanup sprint.
0-39 ๐Ÿ”ด BLACKOUT Critical issues. Stop building, start fixing.

Each dimension scores 0-10, weighted into the overall score. Weights are configurable.


Supported Languages

Language Scan Fix Auto-Fix
JavaScript / TypeScript โœ… โœ… โœ…
Python โœ… โœ… โœ…
Go โœ… โœ… ๐Ÿ”œ
Rust โœ… โœ… ๐Ÿ”œ
Java โœ… โœ… ๐Ÿ”œ
Ruby โœ… ๐Ÿ”œ ๐Ÿ”œ
PHP โœ… ๐Ÿ”œ ๐Ÿ”œ
C/C++ โœ… ๐Ÿ”œ ๐Ÿ”œ

Language-agnostic checks (duplication, dead code, dependencies, security) work for all languages.


Config

Zero config to start. Customize with .soberrc.json in your project root:

{
  "thresholds": {
    "god_file_lines": 500,
    "max_nesting": 4,
    "min_test_coverage": 60,
    "duplication_similarity": 70
  },
  "ignore": [
    "node_modules",
    "dist",
    "*.generated.*"
  ],
  "weights": {
    "security": 2.0,
    "architecture": 1.5,
    "duplication": 1.0,
    "error_handling": 1.5,
    "dependencies": 0.8,
    "testing": 1.2,
    "dead_code": 0.8
  },
  "severity": "medium"
}

CI/CD Integration

# GitHub Actions
- name: Sober Check
  run: npx sober-coding scan . --ci --fail-on=critical
# GitLab CI
sober-check:
  script:
    - npx sober-coding scan . --ci --fail-on=high
  allow_failure: false

CI mode outputs SARIF format, compatible with GitHub Code Scanning.


vs. Others

Sober Coding pyscn ESLint/Ruff SonarQube
Built for vibe coding โœ… โœ… โŒ โŒ
Language-agnostic โœ… โŒ Python only โŒ per-language โœ…
Debt scoring โœ… 0-100 โœ… โŒ โœ…
AI pattern detection โœ… โœ… โŒ โŒ
Fix suggestions โœ… with code โŒ โŒ partial
Auto-fix โœ… --apply โŒ partial โŒ
Zero config โœ… โœ… โŒ โŒ
Runs locally โœ… โœ… โœ… โŒ server
Claude Code integration โœ… โŒ โŒ โŒ
Free โœ… โœ… โœ… โš ๏ธ freemium

Roadmap

  • Core scanner engine
  • Security checks (SEC-001~005)
  • Architecture checks (ARC-001~005)
  • Duplication detection (DUP-001~003)
  • Error handling checks (ERR-001~004)
  • Dependency checks (DEP-001~003)
  • Testing checks (TST-001~003)
  • Dead code detection (DED-001~004)
  • CLI with scoring
  • Fix suggestions (sober fix <ID>)
  • .soberrc.json config support
  • CI mode (--ci, --fail-on)
  • Auto-fix engine (--apply)
  • HTML/PDF report generation
  • VS Code extension
  • GitHub Action (marketplace)
  • Watch mode (scan on save)
  • AI pattern fingerprinting (detect which AI generated the code)
  • Team dashboard

Star History

Star History Chart


Contributing

PRs welcome. See CONTRIBUTING.md.


License

MIT โ€” Use it, fork it, ship it. Free forever.

About

Wake up from vibe coding. AI-generated code quality analyzer + technical debt fixer. Language-agnostic. Zero config.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors