Skip to content

giovani-junior-dev/code-craftsman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”จ code-craftsman

Always-on quality enforcement for Claude Code. Forces real engineering discipline. Blocks LLM laziness, over-engineering, vibe coding, redundancy. Enforces TDD, Clean Code, flat-first architecture, EARS requirements, mutation testing.

License: MIT Skill Caveman


โš ๏ธ Why this skill exists

LLMs (Claude, GPT, Opus) have deep knowledge of software engineering. But they're trained to iterate โ€” generate simple answer first, wait for you to correct, burn more tokens. More iteration = more revenue for AI companies.

Result: you pay for code worse than what the model can produce.

This skill forces LLM to use real knowledge from the 1st response:

  • โŒ Blocks lazy patterns (Manager, Util, IRepository without 2nd impl, UseCase for CRUD)
  • โŒ Blocks over-engineering (ritualistic Clean Arch, 18 files for 1 feature)
  • โŒ Blocks code without tests (TDD non-negotiable)
  • โŒ Blocks quality regression (Quality Gate ratchet)
  • โœ… Forces flat-first, YAGNI, abstract by real pain
  • โœ… Compresses output (no fluff/pleasantries)
  • โœ… Auto-trigger snapshot/contract/mutation tests
  • โœ… E2E opt-in with recorded ADR

๐Ÿ“Š Measured results

Real test comparing delivery app plan (same prompt, same stack):

Metric Without skill With skill
Plan lines 783 463 (-29%)
EARS requirements 0 7
Mutation testing โŒ โœ…
Snapshot/contract auto-trigger โŒ โœ…
TDD explicit mandate partial complete
E2E opt-in protocol โŒ โœ…

Effectiveness: 92% โ€” forces real discipline without becoming formatting tyranny.


๐Ÿš€ Installation

Claude Code

Option 1 โ€” Direct clone (recommended)

git clone https://github.com/giovani-junior-dev/code-craftsman.git ~/.claude/skills/code-craftsman

Restart Claude Code. Skill appears in any session.

Option 2 โ€” As plugin (future)

# When published to marketplace
claude plugin install code-craftsman

Cursor / Windsurf / Cline / Copilot

Skill follows universal SKILL.md spec. Works in any agent that supports it:

# Cursor
mkdir -p ~/.cursor/skills/
git clone https://github.com/giovani-junior-dev/code-craftsman.git ~/.cursor/skills/code-craftsman

# Windsurf
git clone https://github.com/giovani-junior-dev/code-craftsman.git ~/.codeium/windsurf/skills/code-craftsman

# Cline
git clone https://github.com/giovani-junior-dev/code-craftsman.git ~/.cline/skills/code-craftsman

Gemini CLI

gemini extensions install https://github.com/giovani-junior-dev/code-craftsman

Codex CLI

codex skill add https://github.com/giovani-junior-dev/code-craftsman

Generic (npx skills)

npx skills add giovani-junior-dev/code-craftsman -a <agent>

๐ŸŽฏ Per-project setup (optional, recommended)

After global skill install, activate quality gate in a Node.js/TypeScript project:

cd /path/to/your-project
bash ~/.claude/skills/code-craftsman/install.sh

What it does:

  • Installs dev deps: biome, knip, stryker, dependency-cruiser, jscpd, madge, msw, zod
  • Configures hooks in .claude/settings.json
  • Adds visual statusline
  • Creates .code-craftsman/baseline.json with initial metrics
  • Adds npm scripts: craftsman:check, craftsman:full, etc

After install:

npm run craftsman:check    # Quality gate
npm run craftsman:full     # Macro validation (mutation + security + ratchet)
npm run craftsman:baseline # Reset baseline after intentional improvement

๐ŸŽฎ Available commands

Toggle and state

Command Function
/code-craftsman:on Activate skill
/code-craftsman:off Disable in this session
/code-craftsman:pause 30m Temporary pause
/code-craftsman:status State + metrics
/code-craftsman:bypass <rule> <reason> Specific bypass (creates ADR)

Operations

Command Function
/code-craftsman:install Install in current project
/code-craftsman:report Full report
/code-craftsman:baseline-update Freeze new baseline
/code-craftsman:e2e-decide <feature> Ask about E2E + create ADR

๐Ÿ“ Enforced rules

Functions

  • โ‰ค20 lines
  • โ‰ค2 indentation levels
  • โ‰ค2 parameters (3+ โ†’ encapsulate in object)
  • No boolean flag parameter

Files

  • โ‰ค500 lines total (avg ~200)
  • โ‰ค120 chars per line
  • โ‰ค15 imports

Naming (BLOCKED)

  • โŒ Manager, Processor, Handler, Util, Helper (generic)
  • โŒ I prefix on interfaces (IRepository)
  • โŒ m_, _private, Hungarian Notation
  • โŒ Suffixes: NameString, UserData, OrderInfo

Architecture (BLOCKED)

  • โŒ Interface without 2nd real implementation
  • โŒ UseCase for simple CRUD
  • โŒ DTO/Mapper in 3+ layers without real pain
  • โŒ Preventive dependency inversion (YAGNI)
  • โŒ Cross-domain imports (billing/ imports orders/)

Tests

  • TDD mandatory (RED โ†’ GREEN โ†’ REFACTOR)
  • โ‰ฅ80% coverage on modified files
  • โ‰ฅ70% mutation score (Stryker)
  • 1 assert/test, โ‰ค100ms unit
  • F.I.R.S.T compliance
  • Auto-trigger:
    • UI render โ†’ snapshot test
    • External HTTP โ†’ contract test (Pact/MSW + Zod)
    • Financial logic โ†’ mutation test
    • E2E โ†’ opt-in (asks after feature complete)

Quality Gate Ratchet (only goes up or holds)

  • Lint violations: cannot rise
  • Code duplication: cannot rise
  • Cyclomatic complexity: cannot rise
  • File size violations: cannot rise
  • Test coverage: only holds or rises

๐Ÿงช Per-feature test protocol

1. EARS requirement (When/shall format)
2. ATDD acceptance test (failing)
3. TDD unit loop (red-green-refactor)
4. Auto-trigger:
   โ”œโ”€ UI render? โ†’ snapshot test
   โ”œโ”€ External call? โ†’ contract test
   โ””โ”€ Continue with unit only
5. Mutation testing (Stryker โ‰ฅ70%)
6. Coverage ratchet (changed files โ‰ฅ80%)
7. F.I.R.S.T compliance check
8. E2E question (opt-in with ADR)
9. Final quality gate ratchet
10. PR

๐Ÿ†˜ SPIKE marker (only TDD exception)

For temporary exploration:

// SPIKE: validating Stripe Connect for split payment merchants โ€” expires 2026-05-12
// SPIKE-ISSUE: #234

// exploratory code without tests

Strict rules (enforced):

  • Reason โ‰ฅ15 chars, non-generic (forbidden: testing, wip, tmp)
  • Expiration โ‰ค7 days
  • Issue # required
  • After expires โ†’ blocks editing (force conversion to real or delete)
  • Branch spike/* forbidden to merge into main

๐Ÿ“Š Statusline

Real-time visual indicator:

๐Ÿ”จ craftsman ON โ”‚ ratchet โœ“ โ”‚ cov 82% โ”‚ mut 74% โ”‚ lint 0 โ”‚ โšก -47% tok
State Appearance
Active + green ๐Ÿ”จ craftsman ON โ”‚ ratchet โœ“ โ”‚ cov 82%
Active + regression ๐Ÿ”จ craftsman ON โ”‚ โš ๏ธ ratchet FAIL
Paused ๐Ÿ”จ craftsman โธ paused 24m
Disabled ๐Ÿ”จ craftsman OFF
Bypass active ๐Ÿ”จ craftsman ON โ”‚ โš  2 bypass

๐Ÿ—๏ธ Project structure

code-craftsman/
โ”œโ”€โ”€ SKILL.md                    # Always-active manifesto
โ”œโ”€โ”€ README.md                   # This file
โ”œโ”€โ”€ install.sh                  # Per-project installer
โ”œโ”€โ”€ LICENSE                     # MIT
โ”‚
โ”œโ”€โ”€ scripts/                    # 12 Node.js scripts
โ”‚   โ”œโ”€โ”€ toggle.sh, pause.sh, bypass.sh
โ”‚   โ”œโ”€โ”€ statusline.sh
โ”‚   โ”œโ”€โ”€ quality-gate.js, baseline-init.js, metrics-collector.js
โ”‚   โ”œโ”€โ”€ self-validate.js, coverage-ratchet.js
โ”‚   โ”œโ”€โ”€ tdd-enforcer.js, first-checker.js
โ”‚   โ”œโ”€โ”€ snapshot-validator.js, contract-detector.js
โ”‚   โ””โ”€โ”€ e2e-prompt.js
โ”‚
โ”œโ”€โ”€ hooks/                      # 4 Claude Code hooks
โ”‚   โ”œโ”€โ”€ pre-edit.js             # PreToolUse Write|Edit
โ”‚   โ”œโ”€โ”€ post-edit.js            # PostToolUse Write|Edit
โ”‚   โ”œโ”€โ”€ user-prompt.js          # UserPromptSubmit
โ”‚   โ””โ”€โ”€ stop.js                 # Stop hook
โ”‚
โ”œโ”€โ”€ config/                     # 6 configs
โ”‚   โ”œโ”€โ”€ thresholds.json
โ”‚   โ”œโ”€โ”€ biome.json
โ”‚   โ”œโ”€โ”€ dependency-cruiser.cjs
โ”‚   โ”œโ”€โ”€ stryker.config.json
โ”‚   โ”œโ”€โ”€ knip.json
โ”‚   โ””โ”€โ”€ baseline.template.json
โ”‚
โ”œโ”€โ”€ templates/                  # 11 templates
โ”‚   โ”œโ”€โ”€ ears-requirement.md
โ”‚   โ”œโ”€โ”€ adr.md
โ”‚   โ”œโ”€โ”€ tdd-cycle.md
โ”‚   โ”œโ”€โ”€ unit-test.template
โ”‚   โ”œโ”€โ”€ snapshot-test.template
โ”‚   โ”œโ”€โ”€ contract-test.template
โ”‚   โ”œโ”€โ”€ e2e-playwright.template
โ”‚   โ”œโ”€โ”€ e2e-decision-adr.md     # Structured ADR
โ”‚   โ”œโ”€โ”€ spike-marker.md         # SPIKE protocol
โ”‚   โ”œโ”€โ”€ acceptance-test.template
โ”‚   โ””โ”€โ”€ module-flat.template
โ”‚
โ”œโ”€โ”€ references/                 # 6 knowledge base files
โ”‚   โ”œโ”€โ”€ clean-code-rules.md
โ”‚   โ”œโ”€โ”€ anti-patterns.md
โ”‚   โ”œโ”€โ”€ architecture-rules.md
โ”‚   โ”œโ”€โ”€ tdd-protocol.md
โ”‚   โ”œโ”€โ”€ test-strategy.md
โ”‚   โ””โ”€โ”€ llm-laziness-guard.md
โ”‚
โ”œโ”€โ”€ commands/                   # 9 slash commands
โ”‚   โ”œโ”€โ”€ on.md, off.md, pause.md
โ”‚   โ”œโ”€โ”€ status.md, bypass.md
โ”‚   โ”œโ”€โ”€ report.md, baseline-update.md
โ”‚   โ”œโ”€โ”€ install.md, e2e-decide.md
โ”‚
โ””โ”€โ”€ state/                      # Runtime state
    โ”œโ”€โ”€ enabled.flag
    โ”œโ”€โ”€ session.json
    โ””โ”€โ”€ stats.json

Total: ~57 files, ~240KB


๐Ÿ› ๏ธ Integrated tools stack

The skill orchestrates these free tools:

Tool Function
Biome Lint+format (Rust-based, 10x faster than ESLint+Prettier)
Knip Dead code, circular deps, duplication
Stryker Mutation testing (tests the quality of your tests)
Vitest/Jest Test runner
dependency-cruiser Arch boundaries (forbids cross-imports)
Madge Circular deps visualization
Pact Consumer-driven contracts
MSW Mock Service Worker (HTTP in tests)
Zod / TypeBox Runtime schema validation
Playwright E2E (opt-in)
Semgrep Security scanning (optional)
Gitleaks Secrets detection (optional)

๐Ÿ“š Research sources

Skill built from research on:

Full research documented via NotebookLM.


๐Ÿค Contributing

PRs welcome. Areas of interest:

  • Multi-language support (Python/Go/Rust)
  • Adapters for other IDEs (JetBrains, VS Code extension)
  • CI/CD integration (GitHub Actions workflow template)
  • Mutation testing for other languages
  • SKILL.md internationalization
  • Additional tests validating enforcement

Dev setup

git clone https://github.com/giovani-junior-dev/code-craftsman.git
cd code-craftsman

# Test scripts in isolation
node scripts/tdd-enforcer.js test-file.ts
bash scripts/statusline.sh

Philosophy

This skill applies its own rules to itself. PRs must:

  • Follow caveman style in commits and PRs
  • Not introduce abstraction without real pain (YAGNI)
  • Add tests where applicable
  • Keep scripts โ‰ค500 lines

๐ŸŽฏ Roadmap

  • v1 โ€” Core: hooks, configs, Clean Code rules
  • v2 โ€” Planning enforcement (EARS, mutation, snapshot/contract triggers)
  • v2.1 โ€” Strict SPIKE protocol, structured E2E ADR
  • v3 โ€” Multi-language (Python pytest, Go test)
  • v3.1 โ€” Cloud integrations (GitHub Actions, GitLab CI)
  • v4 โ€” Plugin marketplace publication

โš–๏ธ Supreme principle

Simple code = easy to refactor This skill prefers simple-working over elegant-broken

YAGNI > ritualistic Clean Architecture Measure > opine Force quality from 1st response > iterate


๐Ÿ“œ License

MIT โ€” see LICENSE


๐Ÿ™ Inspiration

"The only way to go fast is to go well." โ€” Robert C. Martin

"AI reflects who you are." โ€” Fabio Akita

"Why use many token when few do trick." โ€” caveman philosophy

About

Always-on quality enforcement skill for Claude Code. Forces TDD, Clean Code, flat-first architecture. Blocks LLM laziness and over-engineering.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors