跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    中文English
    AdamMostofi

    Chisel

    v1.0.1工具与命令
    @adammostofi/chisel

    A tool for carving away excess. Disciplined engineering principle for AI agents.

    GitHub 星标

    1

    月装机量

    42

    近 7 天 9

    综合评分SCORE

    30.5

    生态多维模型

    最近提交

    1 个月前

    2026-07-09

    快速安装与配置

    opencode.json

    写入当前项目的 opencode.json,只对这个仓库生效。

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["@adammostofi/chisel@1.0.1"]
    }

    opencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。

    chisel logo

    A tool for carving away excess.
    Version License Stars Language
    #yagni #minimal-code #ai-discipline #over-engineering-guard

    Chisel is a decision ladder for AI agents: YAGNI, Boy Scout, DRY, Rule of Three, Stdlib First. It catches over-engineering before it happens.


    What is Chisel?

    Carve away everything that isn't the solution. Language-agnostic. Structural, not syntactic.


    Principles

    Principle Meaning
    YAGNI Only build what's needed now. Speculation is waste.
    Boy Scout Leave every file cleaner than you found it.
    DRY Same knowledge lives once. Shape duplication is not knowledge duplication.
    Rule of Three 1 instance = fact. 2 = coincidence. 3 = pattern. Extract at 3.
    Stdlib First Stdlib > new dep. Native > library. <input type="date"> over a date-picker library.
    Bug Fix = Root Cause Grep every caller. Fix where all callers route through, not where the ticket says.
    Comment Convention chisel: prefix. Name the ceiling + upgrade path.

    How It Works -- Two-Pass Model

    Pass 1 -- The Ladder

    An 8-rung decision ladder. Climb sequentially. Stop at the first rung that holds. Each rung filters out a class of over-engineering before you reach for your editor.

    1. YAGNI -- Does this need to exist at all? Speculative need = skip it.
    2. Boy Scout -- If touching existing files, leave them cleaner than found.
    3. DRY -- Already in this codebase? Reuse before rewrite.
    4. Stdlib -- Standard library covers it? Use it.
    5. Native -- Platform feature covers it? <input type="date"> over a picker library.
    6. Installed dep -- Already-installed package solves it? Use it. Never add a new one for what a few lines can do.
    7. One line -- Can it be one line? Write one line.
    8. Minimum code -- Write the minimum that works.

    The ladder is a reflex, not a research project. But it runs after you understand the problem. Read the task and the code it touches first. Trace the real flow end to end. Then climb.

    Pass 2 -- The Discipline Gate

    A diff-driven audit that scans the actual change after every write (in full mode). It checks:

    • Touched files -- were they left cleaner than found? Delete dead code, tighten loose patterns.
    • New abstractions -- Rule of Three check. Fewer than 3 instances? Warn. No interface with one implementation. No factory for one product.
    • New dependencies -- stdlib or native platform could replace them? Flag.
    • chisel: comments -- does each name a ceiling and an upgrade path? Verify.

    Outputs a structured verdict: ship if clean, revise if any check fails.


    Auto vs Manual

    This is the critical clarification. The system has two operating modes and a set of always-active safety guardrails.

    Aspect Behavior
    Pass 1 (Ladder) Runs automatically on every coding turn. The agent always climbs the ladder before writing code. No toggle.
    Pass 2 (Gate) In full mode: auto-runs after every write. In lite mode: manual via /chisel-gate.
    Safety Guardrails Baked into the skill definition. Never simplified away. Always active regardless of mode.
    User Override User says "build the full version" -- chisel steps aside. Delivers what was asked. No re-arguing.

    Safety -- Baked In

    These boundaries are part of the skill definition itself. They do not depend on mode. They are never touched by chisel.

    • Input validation at trust boundaries -- type checks, schema validation, sanitization at HTTP/file/env boundaries.
    • Error handling that prevents data loss -- transaction rollback, partial-write safeguards, distinct catch blocks.
    • Security measures -- authentication, authorization, rate limits, CSRF tokens, CSP headers, encryption, secrets management.
    • Accessibility basics -- ARIA labels, keyboard navigation, focus management, color contrast, screen-reader semantics.
    • Anything the user explicitly requests -- if the user says "I need the full version," build it. No re-arguing.
    • Hardware calibration knobs -- real clocks drift, real sensors read off. Leave the knob.

    Never chisel on understanding. The ladder shortens the solution, never the reading. Trace the whole thing first -- every file the change touches, the actual flow, the data that moves through it -- before picking a rung. Disciplined laziness that skips comprehension ships a confident wrong fix. Read fully, then carve.


    Before / After

    Reference implementations of common tasks. Each pair implements the same spec. The difference is structural, not functional.

    Date picker

    A date-of-birth input with age validation (must be 13+).

      Before: flatpickr library, wrapper component, CSS import, JS event handlers,
              age validation function, error display logic -- 52 lines, 1 dependency
      After:  <input type="date"> with min/max attributes -- 5 lines, zero dependencies,
              native browser date picker UX
      -------------------------------------------------------------------------------------
      -90% LOC  -100% deps  -1 library  +native date picker
    

    Rate limiter

    A decorator that limits function calls to N per time window.

      Before: RateLimitExceeded exception class, RateLimiter class with lock management,
              acquire/release protocol, __call__ for decorator support -- 46 lines,
              3 imports, 3 abstractions
      After:  closure with threading.Lock(), @wraps(fn) -- 22 lines, same imports,
              1 function factory, reuses built-in Lock
      -------------------------------------------------------------------------------------
      -52% LOC  -67% abstractions  -1 exception class  +closure over class
    

    Order processing pipeline

    Business-logic pipeline: order validation, tiered discounts, regional tax, invoice output.

      Before: 5 dataclasses, 2 Enum classes, 2 ABCs, 5 strategy subclasses, 2 factories,
              validation pipeline class, InvoiceGenerator class, OrderProcessor
              orchestration class -- 236 lines, 41 abstractions, 7 imports
      After:  dict input, top-level function, simple conditional logic, list comprehension
              for batch processing -- 32 lines, 2 functions, 1 import
      -------------------------------------------------------------------------------------
      -86% LOC  -95% abstractions  -80% deps  -78% complexity
    

    Benchmark Results

    Analytical comparison of no-skill vs chiseled reference implementations for 7 tasks (6 simple + 1 complex business pipeline). Reference implementations are hand-written to the same spec -- the difference is structural, not functional.

    Combined (All 7 Tasks)

    Metric                No-skill    Chiseled    Reduction
    ──────────────────────────────────────────────────────────
    Lines of code          567          104          -82%
    Tokens (est.)        3,588          944          -74%
    Dependencies            14            6          -57%
    Abstractions            64            8          -88%
    Complexity             140           31          -78%
    File size          15,954 B      3,397 B         -79%
    

    Simple Tasks (6)

    Metric                No-skill    Chiseled    Reduction
    ──────────────────────────────────────────────────────────
    Lines of code          331           72          -78%
    Tokens (est.)        2,259          550          -76%
    Dependencies             9            5          -44%
    Abstractions            23            6          -74%
    Complexity              71           17          -76%
    File size           9,610 B      2,145 B         -78%
    

    Complex Task (Order Pipeline)

    Metric                No-skill    Chiseled    Reduction
    ──────────────────────────────────────────────────────────
    Lines of code          236           32          -86%
    Tokens (est.)        1,329          394          -70%
    Dependencies             5            1          -80%
    Abstractions            41            2          -95%
    Complexity              69           14          -80%
    File size           6,344 B      1,252 B         -80%
    

    Results represent the ceiling of what chisel enables. Real LLM output varies but converges toward these numbers. Methodology and reference implementations in benchmarks/.


    Install

    Add to your opencode.json:

    { "plugin": ["@adammostofi/chisel"] }
    

    Or point at a local checkout:

    { "plugin": ["./path/to/chisel/.opencode/plugins/chisel.mjs"] }
    

    Commands

    Command What it does
    /chisel Report current mode (full, lite, or off).
    /chisel full Set full mode (ladder + auto discipline gate).
    /chisel lite Set lite mode (ladder only, manual gate).
    /chisel off Disable chisel.
    /chisel-gate Trigger discipline gate manually (lite mode).

    Why "chisel"?

    A chisel is a tool for carving away everything that is not the solution. Each strike is deliberate. You do not chisel blindly -- you read the grain first (understand the problem), then carve.

    The name reflects the philosophy: the best code is the code never written. The best abstraction is the one you did not create until the pattern proved itself across three real instances. You do not build for speculation. You build for the shape that exists today, and you leave every file you touch cleaner than you found it.


    FAQ

    Does this mean I can't write abstractions?

    No. It means prove the pattern first. The Rule of Three: 3+ concrete instances before extracting shared code. One instance is a fact. Two is a coincidence. Three is a pattern. Extract at three and let the friction between the instances tell you what shape the abstraction should take.

    What about performance-critical code?

    The ladder picks edge-case-correct options. When two stdlib options are equally terse, the tiebreaker is correctness on empty inputs, boundary values, and edge states. Performance is not sacrificed -- unnecessary code is removed. The code that remains does less, so it runs faster.

    What if I need the full version of something?

    Build it. The Safety section explicitly exempts anything the user asks for. If you say "I need the full configurable version," chisel delivers it without re-arguing.

    Does this work with TypeScript / Python / Go / Rust?

    Yes. The ladder is language-agnostic. Stdlib means your language's standard library. Native means your platform (browser, OS, database engine). The principles apply to any code in any language.

    How is this different from a linter or formatter?

    Linters enforce syntax and style. Chisel enforces structural discipline -- whether code should exist at all, whether it is shaped correctly, whether the abstractions are premature, whether the dependencies are necessary. Chisel catches things linters cannot: YAGNI violations, missing chisel: comments, and Rule of Three failures.

    Do I have to use every rung?

    No. Stop at the first rung that holds. If stdlib covers it (rung 4), you never reach rungs 5-8. The ladder is a filter, not a checklist. Climb only until you find your answer, then stop.

    What if I disagree with chisel?

    Use /chisel off to disable it entirely, or ask for the full version of a specific piece of code. Chisel never re-argues once you make the call.


    License

    MIT. The shortest license that works.