Skip to main content

One ruleset for Claude Code, Codex, Copilot, Cursor, Windsurf, Gemini & Aider — token efficiency + spec-driven development in one CLI.

Project description

🧱 Monolith

One ruleset. Every agent. Spec to ship.

CI License: MIT Python 3.9+ PRs welcome Buy me a coffee

Monolith is a dependency-free CLI that unifies three concerns for AI-assisted development:

  1. Token efficiency — compile one ruleset into Claude Code, OpenAI Codex, and GitHub Copilot's native config files. ~55–70% fewer output tokens.
  2. Spec-Driven Development — a full constitution → specify → clarify → plan → analyze → tasks → implement pipeline with structured specs/<feature>/ artifacts.
  3. Runtime compression — wrap any command with monolith run to compress its output before the agent reads it.
Agent File Monolith manages
Claude Code CLAUDE.md
OpenAI Codex AGENTS.md
GitHub Copilot .github/copilot-instructions.md
Cursor .cursorrules
Windsurf .windsurfrules
Gemini CLI GEMINI.md
Aider CONVENTIONS.md

⚡ Before / After

Without Monolith84 tokens

Great question! I'd be happy to help you figure this out. So, the reason your function is returning None is actually because there's no explicit return statement at the end of the branch. What you'll want to do here is make sure you return the computed value. I hope this helps, and let me know if you have any other questions!

With Monolith19 tokens (−77%)

It returns None because that branch has no return. Return the computed value.

Same answer. ~⅕ the tokens. (Measured by monolith bench.)


📦 Install

Requires Python ≥ 3.9. Dependency-free core.

pipx install monolith-ai      # recommended (isolated, always on PATH)
# or
uv tool install monolith-ai   # if you use uv
# or
pip install monolith-ai

From source:

git clone https://github.com/keyurpatel446/Monolith && cd Monolith
pip install -e .              # or: pip install -e ".[bench]" for exact token counts

🚀 Quickstart

One command sets up your project — it detects your agents, writes the rules, and verifies them (init + apply + doctor in one go):

monolith setup

Only use Claude Code? Scope it (full guide):

monolith setup --agent claude

Then check your projected savings:

monolith stats

Spec-Driven Development

monolith constitution                      # scaffold .monolith/memory/constitution.md
monolith specify user-auth                 # scaffold specs/user-auth/spec.md
monolith specify user-auth --plan \
  --data-model --contracts                 # scaffold all artifacts at once
monolith analyze user-auth                 # check spec ↔ plan ↔ tasks consistency
monolith checklist user-auth               # quality gate before shipping

Install all six SDD slash commands with one command:

monolith hub install sdd

🤖 Claude Code setup

Full guide: docs/agents/claude-code.md

Claude Code reads CLAUDE.md automatically. Monolith writes its rules there. Three steps and you're done:

1. Install

pipx install monolith-ai

2. Set up your project (run once per repo)

monolith setup --agent claude   # writes token rules into CLAUDE.md + verifies

Open Claude Code in the project — rules are active immediately. No app config needed.

3. Install slash commands (optional but recommended)

# SDD workflow — /monolith.specify, /monolith.clarify, etc. inside Claude Code
monolith hub install sdd

# Utilities
monolith hub install concise-commit   # /concise-commit  — one-line commit message
monolith hub install terse-review     # /terse-review    — correctness-only review
monolith hub install explain-diff     # /explain-diff    — bullet summary of diff

4. Add the MCP server (optional — compresses command output inside the session)

claude mcp add monolith-shrink -- monolith mcp

5. Compress command output (optional — wrap any command)

monolith run -- pytest -q        # Claude sees failures + summary only (~90% smaller)
monolith run -- ruff check .     # Claude sees diagnostics + counts
monolith run -- git status       # drops hint noise

For Cursor, Windsurf, Copilot, Codex, Gemini CLI, or Aider — see docs/agents/ or just run monolith setup --agent all to write all 7 config files at once.


🧰 What you get

Token efficiency

Command Description
monolith setup [--agent <agent>|all] [--tier <tier>] One-shot onboarding: init + apply + doctor.
monolith init [--agent <agent>|all] Detect agent files and create .monolith/settings.json.
monolith apply [--agent all|claude|codex|copilot|config] Compile directives into agent configs (idempotent).
monolith tier [name] [--apply] Show or switch the active compression tier.
monolith stats Projected + measured reduction and input cost per file.
monolith bench Run the benchmark corpus and record measured token reduction.
monolith rules list|add|remove [value] Manage custom directives appended to every block.
monolith doctor Verify each configured agent has the Monolith block.

Spec-Driven Development (SDD)

Command Description
monolith constitution Scaffold .monolith/memory/constitution.md — mission, principles, definition of done.
monolith specify <feature> [--plan] [--data-model] [--contracts] Scaffold specs/<feature>/ with templated artifact files.
monolith analyze [feature] Structural cross-artifact check: spec ↔ plan ↔ tasks. Exits 1 on errors.
monolith checklist <feature> [--write] Generate a quality gate checklist pre-checked against existing artifacts.

Task management

Command Description
monolith plan <prd-file> [--force] Parse a PRD/Markdown file into a task tree; writes TASKS.md.
monolith tasks [--emit] List the task tree; --emit re-writes TASKS.md.
monolith task <id> --status todo|doing|done Update a task's status (warns on unmet dependencies).
monolith tasks-to-issues --repo owner/repo Push todo/doing tasks to GitHub Issues (requires GITHUB_TOKEN).

Resource hub & runtime

Command Description
monolith hub list|search|show|install Browse and install curated agent resources. install sdd installs the whole SDD bundle.
monolith shrink [file] [--level lite|full|ultra] Compress verbose output deterministically.
monolith run -- <command> Run a command, compress its output, save full output on failure.
monolith gain Show cumulative token savings from run.
monolith mcp Experimental MCP server exposing shrink over stdio.
monolith scan [--apply] Scan repo for @monolith: task/rule tags and apply them.

Global flag --root <dir> runs against another project directory.


🗺️ SDD pipeline

Monolith ships a full Spec-Driven Development workflow as both CLI commands and installable slash commands (cross-agent via the hub).

constitution → specify → clarify → plan → analyze → tasks → implement

Each feature gets a structured folder:

specs/
└── user-auth/
    ├── spec.md          # requirements + user stories + acceptance criteria
    ├── plan.md          # architecture + stack decisions + edge cases
    ├── tasks.md         # actionable task breakdown with @after: deps
    ├── data-model.md    # entity definitions + relationships
    ├── checklist.md     # quality gate (auto-generated)
    └── contracts/
        └── README.md    # API contract convention + per-endpoint files

Every slash command (e.g. /monolith.specify) installs into .claude/commands/, .codex/prompts/, and .github/prompts/ simultaneously — author once, run anywhere.

monolith hub list              # see all SDD commands + utilities
monolith hub show monolith.specify

🎚️ Tiers

Tier Intensity Projected output reduction*
lite filler removal only ~25–35%
full (default) filler + dense formatting + no over-engineering ~55–65%
ultra telegraphic, bullet-first, every directive ~60–70%

* Projections derived from upstream benchmarks. Run monolith bench for a figure measured on the sample corpus.


🗂️ Task management

Point monolith plan at a PRD or any structured Markdown file. Headings and list items become tasks; nesting becomes parent/child. Wire up dependencies with inline tags — {#slug} names a task and @after:slug depends on it:

# Auth feature
- Design DB schema {#schema}
- Build API @after:schema
  - Add input validation
## Release @after:schema

monolith plan prd.md writes a shared task store under .monolith/tasks/ and a root TASKS.md your agents read as ordinary project context.

For per-feature task tracking, put the PRD in specs/<feature>/spec.md and use monolith analyze <feature> to check coverage.


📚 Documentation


Keywords: reduce Claude Code token usage · Codex AGENTS.md token efficiency · GitHub Copilot instructions to save tokens · Cursor cursorrules token optimization · Windsurf windsurfrules AI rules · Gemini CLI GEMINI.md project instructions · Aider CONVENTIONS.md project rules · compress AI command output test output for LLMs · cross-agent token optimization CLI · spec-driven development AI workflow · one config for Claude Code Codex Copilot Cursor Windsurf Gemini Aider.

🌱 Development & branching

Branch Purpose
master Default / release branch. Merges here trigger CI to tag a release.
develop Integration branch for completed features.
feature/<name> Feature work.
fix/<name> Bug fixes.

CI (.github/workflows/ci.yml) runs the test suite on every push/PR to master and develop. When code is merged to master, it reads the version from pyproject.toml and, if a matching tag does not yet exist, creates the tag vX.Y.Z and a GitHub release. Bump version in pyproject.toml to cut a new release.

python -m unittest discover -s tests -v   # run the tests locally

☕ Support

Monolith is free and MIT-licensed. If it saves you tokens (and money), consider chipping in for a coffee — it genuinely helps keep the project moving. 🙏

Buy me a coffee via PayPal

👉 paypal.me/keyurpatel446

📄 License

MIT © Keyur Patel

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

monolith_ai-0.2.2.tar.gz (87.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

monolith_ai-0.2.2-py3-none-any.whl (57.5 kB view details)

Uploaded Python 3

File details

Details for the file monolith_ai-0.2.2.tar.gz.

File metadata

  • Download URL: monolith_ai-0.2.2.tar.gz
  • Upload date:
  • Size: 87.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for monolith_ai-0.2.2.tar.gz
Algorithm Hash digest
SHA256 5d9b9101a4c101b13be494931f134d4cc1b99283efdc6091a2eab442bf3644db
MD5 15ad76bc612094c08637f046bbc6c282
BLAKE2b-256 7c5449d5f367d2c761ca1cd99a6faa73afea6d98719afc76fe500383ab4677ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for monolith_ai-0.2.2.tar.gz:

Publisher: ci.yml on keyurpatel446/Monolith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file monolith_ai-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: monolith_ai-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 57.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for monolith_ai-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f6048299541e9359e075a55983a74ff7f70acb8c174f37924a5f2db4c384dc4d
MD5 61bb4a32f06c19a7953a48be3263e956
BLAKE2b-256 5e306155f18ecd19f3012941806d179bc7cb8884d87109cadfcc8accc5df01ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for monolith_ai-0.2.2-py3-none-any.whl:

Publisher: ci.yml on keyurpatel446/Monolith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page