{"id":49802217,"url":"https://github.com/crisnahine/chameleon","last_synced_at":"2026-06-06T06:01:42.700Z","repository":{"id":357006905,"uuid":"1234501021","full_name":"crisnahine/chameleon","owner":"crisnahine","description":"Claude Code plugin that learns your repo's conventions and injects archetype-aware guidance per edit, so generated code matches your style on the first try. TypeScript and Ruby on Rails. MIT.","archived":false,"fork":false,"pushed_at":"2026-06-03T11:55:17.000Z","size":5028,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-03T12:14:16.570Z","etag":null,"topics":["ai-coding-assistant","archetype","ast-analysis","claude-code","claude-plugin","code-conventions","code-style","developer-tools","linter","mcp","mcp-server","prompt-engineering","python","ruby-on-rails","typescript"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crisnahine.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-10T09:08:56.000Z","updated_at":"2026-06-03T11:53:29.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/crisnahine/chameleon","commit_stats":null,"previous_names":["crisnahine/chameleon"],"tags_count":71,"template":false,"template_full_name":null,"purl":"pkg:github/crisnahine/chameleon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisnahine%2Fchameleon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisnahine%2Fchameleon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisnahine%2Fchameleon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisnahine%2Fchameleon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crisnahine","download_url":"https://codeload.github.com/crisnahine/chameleon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisnahine%2Fchameleon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33971107,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-06T02:00:07.033Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-coding-assistant","archetype","ast-analysis","claude-code","claude-plugin","code-conventions","code-style","developer-tools","linter","mcp","mcp-server","prompt-engineering","python","ruby-on-rails","typescript"],"created_at":"2026-05-12T15:36:33.062Z","updated_at":"2026-06-06T06:01:42.677Z","avatar_url":"https://github.com/crisnahine.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chameleon\n\n\u003e *\"Code that blends in.\"*\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![Claude Code](https://img.shields.io/badge/Claude%20Code-plugin-7C3AED.svg)](https://docs.claude.com/claude-code)\n\nchameleon learns your repo's actual conventions and injects archetype-aware guidance per-edit, so AI-generated code matches your existing style on the first try. Supports TypeScript and Ruby on Rails.\n\n## Quickstart\n\n**Before you start**, you need `uv` and Node.js 20+ on your `PATH`. Ruby 3.0+ is also needed if you edit Rails repos. On a fresh machine, [docs/install.md](docs/install.md) has copy-paste setup for macOS, Linux, and Windows, plus a check for each tool. Skip ahead if you already have them.\n\n**1. Install the plugin.** In any Claude Code session:\n\n```\n/plugin marketplace add crisnahine/chameleon\n/plugin install chameleon@chameleon\n```\n\nRestart Claude Code. Confirm it loaded by asking *\"What chameleon tools do you have?\"*\n\n**2. Profile a repo.** Open a TypeScript or Ruby on Rails repo, then:\n\n```\n/chameleon-init    # build a profile (3-10s for repos under 5k files)\n/chameleon-trust   # approve it for your user\n```\n\nAfter that, every Edit/Write in that repo gets archetype-aware context automatically.\n\n## Why\n\nAI-generated code in established codebases routinely violates local conventions: wrong file location, off-pattern naming, missed team idioms, divergent error handling. Reviewer time gets spent on style and shape instead of logic and security.\n\nchameleon clusters your actual code patterns (AST + statistical analysis), captures team-specific idioms (`/chameleon-teach`), and injects archetype-keyed guidance per-edit so the model writes code that fits.\n\n## How it works\n\n1. **Bootstrap.** `/chameleon-init` runs an AST scan, clusters files into archetypes by a 7-tuple signature, picks a canonical example per archetype, and writes `.chameleon/profile.json` — committed to git, team-shared.\n\n2. **Trust.** `/chameleon-trust` is a per-user, per-repo approval gate. Same mental model as `git config --get user.signingkey`: the profile lives in the repo, the trust grant lives on your machine.\n\n3. **Per-edit context.** Before every Edit/Write/NotebookEdit, the `PreToolUse` hook calls the chameleon MCP server, which returns the matched archetype's canonical excerpt, rules, and idioms. The hook injects `\u003cchameleon-context\u003e` into the model's context.\n\n4. **Teach.** `/chameleon-teach` captures idioms an AST can't infer — banned imports, mandatory wrappers, custom HTTP clients, internal conventions. Persisted to `.chameleon/idioms.md` and surfaced through the trust gate so reviewers see them before granting trust.\n\n5. **Drift detection.** Per-edit confidence is tracked in `~/.local/share/chameleon/\u003crepo_id\u003e/drift.db`. When the profile no longer matches reality, `/chameleon-status` escalates and recommends `/chameleon-refresh`.\n\nBecause the skills trigger automatically, you don't need to do anything special after install. Edits in a trusted, profiled repo just blend in.\n\n## Install\n\nThe [Quickstart](#quickstart) above has the two commands for Claude Code. For the full guide - per-OS prerequisite setup (macOS, Linux, Windows), verification, updating, uninstall, and troubleshooting - see **[docs/install.md](docs/install.md)**.\n\n## Workflow\n\n1. **`/chameleon-init`** — bootstrap a profile. Runs the AST scan, clusters files into archetypes, selects canonical examples, writes `.chameleon/profile.json`. Commit the result.\n\n2. **`/chameleon-trust`** — review and approve the committed profile for your user. Asks you to type the repo's basename to confirm. Trust state lives at `~/.local/share/chameleon/\u003crepo_id\u003e/.trust`.\n\n3. **Edit normally.** The `PreToolUse` hook looks up the target file's archetype, fetches the canonical excerpt + rules + active idioms, and injects them as `\u003cchameleon-context\u003e` before the edit lands. The model references the canonical example and writes code that fits.\n\n4. **`/chameleon-teach`** — capture missed patterns as team idioms. Persists to `.chameleon/idioms.md` and survives `/chameleon-refresh`.\n\n5. **`/chameleon-status`** — check profile state, drift score, and plugin health. High drift recommends `/chameleon-refresh` to re-cluster against the current code.\n\n6. **`/chameleon-refresh`** — re-run the bootstrap after meaningful team changes. Existing idioms are preserved; the trust grant must be re-issued because the profile SHA changes.\n\n## What's Inside\n\n### Slash commands\n\n| Command | Purpose |\n|---|---|\n| `/chameleon-init` | Bootstrap a new profile |\n| `/chameleon-refresh` | Re-analyze and update profile after team changes |\n| `/chameleon-status` | View profile state, drift score, plugin health |\n| `/chameleon-teach` | Capture a missed pattern as a team idiom |\n| `/chameleon-auto-idiom` | Derive novel team idioms from repo evidence (append-only, deduplicated against the profile) |\n| `/chameleon-trust` | Approve a committed profile for your user |\n| `/chameleon-disable` | Suppress chameleon for the rest of this session |\n| `/chameleon-pause-15m` | Pause for 15 minutes (auto-resume) |\n| `/chameleon-doctor` | Run health checks on the chameleon installation |\n| `/chameleon-journey` | Run the end-to-end journey test harness |\n| `/chameleon-pr-review` | Review a branch/PR against the repo's conventions and task intent |\n\n`using-chameleon` is one more skill on top of these — it auto-fires on `SessionStart` and orients the model.\n\n### Hooks\n\nFive hooks drive the runtime:\n\n- **SessionStart** — detects the repo, loads the profile, and announces archetype awareness to the model.\n- **PreToolUse** — fires on Edit/Write/NotebookEdit; injects `\u003cchameleon-context\u003e` with the archetype's canonical excerpt, rules, and idioms.\n- **PostToolUse (recorder)** — fires on Bash/Edit/Write/NotebookEdit; records drift signals for `/chameleon-status`.\n- **PostToolUse (verify)** — fires on Edit/Write/NotebookEdit; runs archetype conformance lint on the written file.\n- **UserPromptSubmit** — detects frustration phrases and surfaces disable/pause/teach options.\n\n### MCP server\n\n`chameleon-mcp` (Python, FastMCP, stdio transport) exposes 34 tools, including `detect_repo`, `get_archetype`, `get_pattern_context`, `get_canonical_excerpt`, `get_rules`, `lint_file`, `get_drift_status`, `refresh_repo`, `bootstrap_repo`, `list_profiles`, `merge_profiles`, `teach_profile`, `teach_profile_structured`, `teach_competing_import`, `get_idiom_coverage`, `check_idiom_candidates`, `trust_profile`, `disable_session`, `pause_session`, `propose_archetype_renames`, `apply_archetype_renames`, `daemon_status`, `doctor`, plus the review-gate tools (`query_symbol_importers`, `get_crossfile_context`, `get_duplication_candidates`, `get_shadow_report`, `get_override_audit`, `get_longitudinal_signals`, `get_review_history`, `record_review_verdict`, `explain_edit`, `dep_audit`, `get_status`). The full table lives in [docs/architecture.md](./docs/architecture.md).\n\n### Opt-out hierarchy\n\nMost-permanent → most-temporary:\n\n```\n.chameleon/.skip          per-repo, all users (committed)\nCHAMELEON_DISABLE=1       per-user globally (in your shell rc)\nCHAMELEON_VERIFY=0        disable post-edit verification only\n/chameleon-disable        this session only\n/chameleon-pause-15m      next 15 minutes (auto-resume)\n```\n\n## Philosophy\n\n- **Evidence over assumption** — cluster what the repo actually does; don't assume a framework's defaults match this team's style.\n- **Atomic and reviewable** — profile writes use a flock-serialized `COMMITTED` sentinel; the trust gate surfaces idioms verbatim so reviewers see what they're approving.\n- **Fail closed** — the canonical-selection pipeline rejects candidates that fail secret, injection, or poisoning scans; the profile is shipped with no example before it is shipped with a poisoned one.\n- **Opt-out at every layer** — five ways to silence the plugin, from committed repo flag to a 15-minute pause.\n\nSee [docs/architecture.md](docs/architecture.md) for the full design: bootstrap pipeline, cluster signature function, atomic profile commit, drift model, and security mitigations.\n\n## Contributing\n\nSee [.github/CONTRIBUTING.md](.github/CONTRIBUTING.md) for dev setup, test workflows, and the change conventions used in this repo. Contributors hacking on the plugin itself should use `--plugin-dir`, not the marketplace install above.\n\n## License\n\nMIT — see [LICENSE](LICENSE).\n\n## Author\n\nCris Nahine — [crisjosephnahine@gmail.com](mailto:crisjosephnahine@gmail.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrisnahine%2Fchameleon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrisnahine%2Fchameleon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrisnahine%2Fchameleon/lists"}