# claude-clean-context — Context-Window Hygiene & Memory Blueprint — Complete AI & LLM Reference Corpus (`llms-full.txt`) - Repository: https://github.com/mohan-n-swamy/claude-clean-context - Web Discovery URL: https://mohan-n-swamy.github.io/repos/claude-clean-context/ - License: MIT - Keywords: claude-code, context-engineering, llm-optimization, token-optimization, ai-agents, claude-skills, developer-tools, python, cli --- ## File: `AI-README.md` — AI-README.md --- repo: "mohan-n-swamy/claude-clean-context" title: "claude-clean-context — Context-Window Hygiene & Memory Blueprint" license: "MIT" keywords: [claude-code, context-engineering, llm-optimization, token-optimization, ai-agents, claude-skills, developer-tools, python, cli] capabilities: - "A context-window hygiene architecture and implementation blueprint that keeps always-loaded `CLAUDE.md` / `AGENTS.md` instructions compact while routing project memory and on-demand skills cleanly." - "Complete human and machine documentation pack (`AI-README.md`, `llms.txt`, `AGENTS.md`, `PRD`, `PR-FAQ`, `HLD`, `LLD`, `RESEARCH-2026`)." when_to_use: - "A context-window hygiene architecture and implementation blueprint that keeps always-loaded `CLAUDE.md` / `AGENTS.md` instructions compact while routing project memory and on-demand skills cleanly." - "Stuffing every past lesson, schema, and runbook into `CLAUDE.md` consumes 25K+ tokens on turn one and degrades instruction following across every prompt. `claude-clean-context` separates tiny standing rules from on-demand skills and indexed semantic retrieval." inputs_required: - "LOG_LEVEL: Optional diagnostic verbosity control" quickstart: - "ls doctrine/ blueprint/ docs/" - "cat doctrine/CLAUDE.md.template" --- # claude-clean-context — Context-Window Hygiene & Memory Blueprint — Machine-Readable Agent Guide A context-window hygiene architecture and implementation blueprint that keeps always-loaded `CLAUDE.md` / `AGENTS.md` instructions compact while routing project memory and on-demand skills cleanly. Stuffing every past lesson, schema, and runbook into `CLAUDE.md` consumes 25K+ tokens on turn one and degrades instruction following across every prompt. `claude-clean-context` separates tiny standing rules from on-demand skills and indexed semantic retrieval. Key modules and entry points in this repository: - `README.md & AI-README.md`: Human quickstart and machine-readable adaptation guide - `docs/`: PRD, Working-Backwards PR-FAQ, HLD, LLD, and 2026 research notes Every organization-specific value enters through `.env` (copied from `.env.example`) or external adapter files. No source edit is needed to change organization names, endpoints, database URLs, webhook secrets, or thresholds. When a human asks an AI coding agent to deploy or adapt `claude-clean-context` into their stack: 1. Follow the quickstart in `README.md` (`ls doctrine/ blueprint/ docs/`). 2. Point your AI coding assistant at `AI-README.md` to tailor configuration to your workspace. - Product Requirements: `docs/PRD.md` - Working-Backwards PR-FAQ: `docs/PR-FAQ.md` - High-Level Architecture: `docs/HLD.md` - Low-Level Interfaces & Runbook: `docs/LLD.md` - Coding Agent Rules: `AGENTS.md` --- ## File: `.env.example` — Environment Contract (.env.example) ```ini # claude-clean-context — Context-Window Hygiene & Memory Blueprint — Environment Contract # Copy to .env and set values for your organization. # Optional diagnostic verbosity control LOG_LEVEL=info ``` --- ## File: `AGENTS.md` — AGENTS.md # AGENTS.md — claude-clean-context — Context-Window Hygiene & Memory Blueprint Read this file first before modifying `claude-clean-context`. ## Purpose A context-window hygiene architecture and implementation blueprint that keeps always-loaded `CLAUDE.md` / `AGENTS.md` instructions compact while routing project memory and on-demand skills cleanly. ## Commands ```bash ls doctrine/ blueprint/ docs/ cat doctrine/CLAUDE.md.template ``` ## Module Map - `README.md & AI-README.md`: Human quickstart and machine-readable adaptation guide - `docs/`: PRD, Working-Backwards PR-FAQ, HLD, LLD, and 2026 research notes ## Invariants 1. Keep all organization names, credentials, domains, and thresholds in `.env` or external config files. Never hardcode company names, host IPs, or secrets in source files. 2. Deterministic business logic belongs in code and lookup tables, not inside LLM prompts. 3. Update `docs/HLD.md`, `docs/LLD.md`, and `.env.example` in the same commit whenever an interface or environment variable changes. 4. Run the repository smoke check and secret scan before opening a pull request. --- ## File: `docs/PRD.md` — Product Requirements Document (docs/PRD.md) # Product Requirements Document — claude-clean-context — Context-Window Hygiene & Memory Blueprint A context-window hygiene architecture and implementation blueprint that keeps always-loaded `CLAUDE.md` / `AGENTS.md` instructions compact while routing project memory and on-demand skills cleanly. ## 1. Problem Stuffing every past lesson, schema, and runbook into `CLAUDE.md` consumes 25K+ tokens on turn one and degrades instruction following across every prompt. `claude-clean-context` separates tiny standing rules from on-demand skills and indexed semantic retrieval. ## 2. Users and Jobs-to-be-Done | Persona | Job-to-be-Done | |---|---| | AI-Assisted Software Engineer | Adopt `claude-clean-context` in under five minutes using standard CLI workflows. | | Coding Agent (Claude / Codex / Cursor) | Read `AI-README.md` and `llms.txt` to integrate or extend the tool autonomously. | ## 3. Core Capabilities - A context-window hygiene architecture and implementation blueprint that keeps always-loaded `CLAUDE.md` / `AGENTS.md` instructions compact while routing project memory and on-demand skills cleanly. - Complete human and machine documentation pack (`AI-README.md`, `llms.txt`, `AGENTS.md`, `PRD`, `PR-FAQ`, `HLD`, `LLD`, `RESEARCH-2026`). ## 4. Configurable Inputs Adopters configure the system for their own organization without editing core application logic: | Variable | Default / Example | Purpose | |---|---|---| | `LOG_LEVEL` | `info` | Optional diagnostic verbosity control | ## 5. Phasing and Stability Exit Criteria 1. **Phase 1 (Local Synthetic Run):** Clone the repository, copy `.env.example` to `.env`, and run the quickstart commands against synthetic seed data. Exit criterion: smoke checks pass with zero external credentials. 2. **Phase 2 (Read-Only Shadow Wiring):** Connect read-only credentials or webhook listeners in shadow/dry-run mode. Exit criterion: 100 consecutive events or queries reconcile cleanly against source records. 3. **Phase 3 (Production Cutover):** Enable live writes, alerts, or routing behind bounded retry and idempotency guards. ## 6. Non-Goals - Shipping organization-specific business rules hardcoded in application source. - Storing credentials, personal customer records, or tenant URLs inside version control. - Replacing deterministic validation or arithmetic with unconstrained model prompts. --- ## File: `docs/PR-FAQ.md` — Working-Backwards PR-FAQ (docs/PR-FAQ.md) # Working-Backwards PR-FAQ — claude-clean-context — Context-Window Hygiene & Memory Blueprint **Release Summary:** `claude-clean-context` gives engineering and operations teams a self-hosted, open-source implementation of claude-clean-context — Context-Window Hygiene & Memory Blueprint that configures via `.env` and runs on standard infrastructure in minutes. ## Press Release Operations and engineering teams often rebuild the same internal workflows behind closed doors or pay per-seat SaaS markups for rigid tools that cannot match their field reality. `claude-clean-context` open-sources a battle-tested implementation of claude-clean-context — Context-Window Hygiene & Memory Blueprint, stripped of all single-company assumptions and packaged with clear adapter boundaries, synthetic demo data, and machine-readable agent documentation. Any team can fork `claude-clean-context`, supply their own `.env` inputs and taxonomy config, and deploy locally or in production with Docker, Python, or Node. AI coding assistants such as Claude Code, Codex, and Cursor can read `AI-README.md` and `llms.txt` to wire custom ERP, CRM, or warehouse adapters in a single session. ## External Adopter FAQ **Q1: How long does it take to run locally after cloning?** Under five minutes. Copy `.env.example` to `.env` and run the quickstart commands in `README.md`. Synthetic fixtures let you inspect the workflow before connecting live credentials. **Q2: Do I need to rewrite source files to use my own company name, channels, or rules?** No. Organization names, endpoints, thresholds, and credentials sit in `.env` and declarative config files. External system specifics live behind narrow adapter modules documented in `docs/LLD.md`. **Q3: What license governs this repository?** MIT License. You can fork, modify, self-host, and use it commercially without restriction. ## Internal Engineering & Security FAQ **Q4: How do we prevent tenant or employer data from ever entering a public fork?** The repository starts from a clean git history, excludes raw exports and binary dumps, validates every commit through `gitleaks`, and ships only synthetic fixtures. **Q5: What happens when an upstream API or model provider is slow or unavailable?** Inbound webhooks persist raw payloads before processing, outbound writes carry idempotency keys with bounded exponential backoff, and model-backed paths fail open to deterministic rules or explicit human queues. --- ## File: `docs/HLD.md` — High-Level Design (docs/HLD.md) # High-Level Design (HLD) — claude-clean-context — Context-Window Hygiene & Memory Blueprint A context-window hygiene architecture and implementation blueprint that keeps always-loaded `CLAUDE.md` / `AGENTS.md` instructions compact while routing project memory and on-demand skills cleanly. ## 1. System Topology ```mermaid flowchart LR Dev["Developer / Agent"] --> CLI["CLI / Blueprint Entrypoint"] CLI --> State["Local Git / Config State"] State --> Out["Verified Deterministic Output"] ``` ## 2. Architectural Decisions and Rejected Alternatives | Decision | Why It Holds | Rejected Alternative | |---|---|---| | Local-first files and deterministic CLI outputs | Keeps latency near zero, preserves privacy, and composes cleanly in shell scripts and agent hooks. | Hosted SaaS dashboard requiring account signup | ## 3. Data Flow and Failure Boundaries 1. **Configuration Boundary:** Startup validates `.env` variables and declarative config schemas before accepting traffic or running scheduled jobs. 2. **Adapter Boundary:** External services (databases, chat channels, HRMS, warehouses, or LLM providers) sit behind explicit adapter modules so failures stay isolated and testable with local mocks. 3. **Observability and Audit:** State transitions and job executions emit structured logs and deterministic status records rather than mutating state silently. ## 4. Scaling Notes - **1x to 10x load:** Single-node Docker Compose or process supervisor handles standard team workloads with indexed database queries and bounded worker concurrency. - **First bottleneck at 10x+:** High-frequency webhook or batch ingestion queues; mitigate by separating the stateless HTTP receiver from background worker processes sharing Redis or PostgreSQL locks. --- ## File: `docs/LLD.md` — Low-Level Design & Runbook (docs/LLD.md) # Low-Level Design (LLD) & Operations Runbook — claude-clean-context — Context-Window Hygiene & Memory Blueprint This document defines the module responsibilities, environment contract, and operational procedures for `claude-clean-context`. ## 1. Module and File Inventory | Path | Responsibility | |---|---| | `README.md & AI-README.md` | Human quickstart and machine-readable adaptation guide | | `docs/` | PRD, Working-Backwards PR-FAQ, HLD, LLD, and 2026 research notes | ## 2. Environment Variable Contract | Variable | Default / Example | Required | Description | |---|---|---|---| | `LOG_LEVEL` | `info` | Yes | Optional diagnostic verbosity control | ## 3. Extension Recipe 1. Follow the quickstart in `README.md` (`ls doctrine/ blueprint/ docs/`). 2. Point your AI coding assistant at `AI-README.md` to tailor configuration to your workspace. ## 4. Operations Runbook ### 1. Verify installation / repository state ```bash ls doctrine/ blueprint/ docs/ ``` --- ## File: `docs/RESEARCH-2026.md` — 2026 Research & Landscape Notes (docs/RESEARCH-2026.md) # 2026 Ecosystem Research & Design Notes — claude-clean-context — Context-Window Hygiene & Memory Blueprint A context-window hygiene architecture and implementation blueprint that keeps always-loaded `CLAUDE.md` / `AGENTS.md` instructions compact while routing project memory and on-demand skills cleanly. ## 1. Landscape Comparison Teams evaluating open-source options in this domain typically choose between heavyweight multi-tenant SaaS platforms, brittle no-code glue scripts, or unmaintained prototypes that hardcode single-company schemas. `claude-clean-context` occupies the self-hosted production middle ground: narrow adapter interfaces, deterministic state invariants, and zero vendor lock-in. ## 2. Standards and Agent Interoperability Applied 1. **Dual Human + Machine Discovery (`AGENTS.md`, `AI-README.md`, `llms.txt`):** Structured so AI coding assistants (Claude Code, Codex, Cursor, Windsurf, Antigravity) can inspect capabilities, required `.env` inputs, and adapter hooks without scanning thousands of lines of source code. 2. **Environment-First Configuration (12-Factor + Adapter Pattern):** Every tenant name, endpoint, threshold, and credential enters via `.env` or declarative config files. 3. **Deterministic Guardrails Before Model Calls:** Routing, validation, deduplication, and state transitions execute in deterministic code; model calls handle only unstructured synthesis or classification with schema validation.