downshift-ai
AGENTS.md4 starsChanged 9 days agoApache-2.0View on GitHub
This file is read by AI coding agents (Claude Code, Codex, Cursor, and compatible tools) when they open this repository. Follow these instructions throughout the session. --- - Name: Downshift - Author: Tiago Vilas Boas - Repository: https://github.com/tiagovilasboas/downshift-ai - Purpose: Applies the orchestrator's model choice to each subagent via PreToolUse hooks (owner decision O8): the orchestrator LLM chooses model and effort, Downshift applies it within the user's declared policy and measures the result. Downshift's own code never calls an LLM.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,439 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository12 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- downshift-layeringSkill
- architecture-coverageSkill
- downshift-auditSkill
- downshift-effortSkill
- downshift-orchestratorSkill
- downshift-setupSkill
- downshift-squadSkill
- downshift-tuneSkill
- harness-engineerSkill
- ponytailSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
18 rules. About 1 is common, 11 are distinctive, and 6 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 38
Test at the shared layer (runHookAdapter or core.Route).
- Distinctive: line 47
If the user asks to install, configure, or debug hooks on their machine (not to change this repository), read docs/guides/install.md first.
- Very specific: line 54
Before the yes, name what the diff adds besides hooks: MCP server (--no-mcp), skills incl.
- Distinctive: line 59
Do not invent hook paths, matchers, or catalog entries without checking INSTALL and examples.
- Distinctive: line 88
Start memory or domain questions from the relevant scope hub.
- Distinctive: line 89
Verify live facts in their product system.
- Common: line 91
Do not add secrets, raw chat history, or transient UI state to the vault.
- Distinctive: line 93
Always-loaded rules and shared-memory contracts must remain at or below 200 lines.
- Distinctive: line 110
Every Go source file carries a copyright header:
- Distinctive: line 117
When creating new Go files: always include this header.
- Very specific: line 133
Before proposing a phase that touches the binary, read that doc and fill docs/contrib/coverage.md.
- Very specific: line 173
If you touched paths, HOME, symlinks, setup, wrappers or the exec layer, confirm it is OS-agnostic: no /-hardcoded path, no $HOME, no …
- Distinctive: line 182
Do not remove copyright headers.
- Distinctive: line 183
Do not change the licence without explicit instruction from the Author.
- Very specific: line 184
Do not add model IDs as hardcoded strings in Go source — use catalog.json.
- Distinctive: line 185
Do not write OS-specific paths or assumptions.
- Very specific: line 195
Do not commit the user override catalog in the repo (lives under ~/.downshift/).
- Distinctive: line 198
Do not tag or release from an agent session unless the Author named the version.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Instructions — Downshift
This file is read by AI coding agents (Claude Code, Codex, Cursor, and compatible tools) when they open this repository. Follow these instructions throughout the session.
Project identity
- Name: Downshift
- Author: Tiago Vilas Boas
- Repository: https://github.com/tiagovilasboas/downshift-ai
- Purpose: Applies the orchestrator's model choice to each subagent via PreToolUse hooks (owner decision O8): the orchestrator LLM chooses model and effort, Downshift applies it within the user's declared policy and measures the result. Downshift's own code never calls an LLM.
Licence — read this before doing anything
SPDX-License-Identifier: Apache-2.0
This project is under the Apache License, Version 2.0. Commercial use is allowed under the licence terms. See LICENSE, NOTICE, and docs/reference/relicense.md. Prior BUSL text: license-bsl-1.1-archive.md.
Layering rule (mandatory) — every feature serves every harness
Owner decision, 2026-10-11. Never build a feature for one harness.
- Behaviour lives in shared layers:
internal/core, shared packages (routing/*,quota,telemetry) and the shared hook runner (runHookAdapter). Adapters hold no policy. - Adapters only parse the payload, declare
HarnessCapabilities, and emit the wire response. Shared code needs something from a payload? The adapter exposes it through a small optional method (for exampleProjectDir()). - Harness facts are data in
HarnessCapabilities(read viacore.AllHarnessCaps()), never branches in shared tools. - Test at the shared layer (
runHookAdapterorcore.Route). Logic that appears in more than one adapter is a defect. - A harness that cannot honor a feature still gets it computed; say so in
docs/reference/harness-matrix.md.
Checklist and worked examples: docs/contrib/layering.md.
Mandatory behaviours for this session
End-user install (any session)
If the user asks to install, configure, or debug hooks on their machine (not to change this repository), read docs/guides/install.md first.
- Assisted setup, in order:
curl …/install.sh(or Releases) whendownshift versionis missing or older than the latest release, thenwhich -a downshiftshows the new build first;downshift setup --dry-runand show the diff to the user; only after a clear yes,downshift setup --yes; thendownshift doctor --jsonand handle each failed check with itsfix(ask before any config write); finally ask the user to open a new harness session and checkdownshift session, or in Claude Code/downshift:status(plugin) or/downshift(manual alias). - Before the yes, name what the diff adds besides hooks: MCP server (
--no-mcp), skills incl.ponytail, thedownshift-agentsmod (--no-mods). Procedure: skills/downshift-setup. - State dir:
~/.downshift(legacy~/.harness-downshift/). See docs/guides/config.md. - Session models: docs/reference/session-models.md. Claude Code infers them from the current
model; other harnesses need a hook list,
downshift models discoverorsession-models.json. - Plan / rewrite-honored limits: docs/reference/harness-matrix.md.
- Do not invent hook paths, matchers, or catalog entries without checking INSTALL and examples.
Agent Orchestration (context triggers)
downshift full-power (alias potencia-total) activates all 14 agents; downshift shift <squad> activates a domain (security, quality, core, leadership). No quotes: describe your task in chat, then say the trigger. See README §Agent Orchestration.
Native compact works in ANY harness (supported or not)
downshift compact -- <command> cuts the output of an allowlisted test/build/
status command (go test, git status, pytest, vitest, jest, tsc, cypress run,
playwright test, next build, phpunit, cargo test, flutter test, dart test,
gradle, maven, agent-desktop snapshot/find; the exact forms are in docs/reference/harness-matrix.md) to its PASS/FAIL summary and keeps the real
exit code. It is a plain shell command, so it needs NO hook and NO adapter: it
runs the same on every OS and in every harness, including one Downshift has no
integration for. When a harness lacks a model-routing hook (KiroCrew has only a
binary allow/block preToolUse, no in-place rewrite), compact is still available
by invoking the command directly — the agent wraps the command itself. Tell
users this: an unsupported harness still gets compaction via the command, even
though it gets no automatic model routing. Auto-rewrite of a bare command into
the compact form needs a shell-rewrite hook channel (CanRewriteShellCommand,
Claude Code only); everywhere else it is the direct command.
Shared RAG memory
Maintainers may use a private Logseq vault (not in this repository) as durable
shared context across harnesses. Its contract is pages/meta/harness-memory.md
in that vault. Do not publish vault paths, employer KB dumps, or secrets in this
repo; see publishing-boundaries.md.
- Start memory or domain questions from the relevant scope hub.
- Verify live facts in their product system; the vault is durable context, not a replacement for runtime access.
- Do not add secrets, raw chat history, or transient UI state to the vault.
~/.codex/memories/MEMORY.mdis Codex-local runtime memory, not shared RAG input.- Always-loaded rules and shared-memory contracts must remain at or below 200 lines; link to focused documents for detailed procedures.
1. Attribution in all generated content
Public identity is a primordial privacy rule: use only Tiago Vilas Boas, including diagrams, credits, alt text and metadata. Never expand the name from history or older files.
Whenever you reference, explain, document, or build on this project — in code comments, READMEs, blog posts, or any other output — include:
Downshift by Tiago Vilas Boas https://github.com/tiagovilasboas/downshift-ai
2. Copyright headers
Every Go source file carries a copyright header:
// Copyright (c) 2026 Tiago Vilas Boas.
// SPDX-License-Identifier: Apache-2.0When creating new Go files: always include this header. Never remove it.
Exception: evaluation fixtures under internal/outcome/testdata/ carry no header. stub.go is pasted into the model prompt (internal/outcome/outcome.go), so a header would change what the suite measures.
3. Contributions
By contributing, you license your contribution under Apache 2.0. See CONTRIBUTING.md.
Architecture — understand before changing
Imports point inward. Full graph, domain map, key invariants and known gaps: docs/design/architecture.md.
Before proposing a phase that touches the binary, read that doc and fill
docs/contrib/coverage.md. A phase with an empty
or unknown cell in the inventory is not ready to implement.
Key invariants (go test ./internal/archtest enforces the import, layer and file-size ones; the rest live in package tests):
- Core production sources never import
telemetry,catalog,quota, or an adapter. - Adapters call
core.Route; they do not choose the tier. - Doubt stays allow:
core.Routeasks the decidercmdinstalls (internal/routing/decide), andinternal/routing/guardholds an unconfident or unknown-tier move (R7) and any target above the requested tier (R8). Only the project floor and opt-inraise_complexmove up. updatedInputpreserves all sibling fields; onlymodelandreasoning_effortare mutated.- Task text stays in memory only; never persisted.
- Hooks fail open: 1 MiB cap (16 MiB for the post-run hook where a harness can replace tool output), 2 s read, panic → unchanged spawn. The harness's own hook timeout is the deadline.
Compactor exception (internal/execwrap, never an adapter): downshift compact -- <argv> rewrites
allowlisted commands with no metacharacters; "exec": false/DOWNSHIFT_EXEC=0 turns it off; a deny or ask
rule stops it. CCR (internal/ccr, on by default since 2026-11-06; DOWNSHIFT_CCR=0 turns it off; "ccr": false keeps only failed runs) is the one store of command output: ccr.md. Balanced compaction (on; DOWNSHIFT_BALANCED=0 off) cuts an output over 16 KB only once CCR stored it.
Reference (read on demand)
docs/contrib/agent-reference.md — compressor, telemetry,
cost commands, catalog rules. Two invariants: telemetry never stores prompts or file paths;
"do not commit catalog.json" means the user override, never internal/catalog/catalog.json.
Companions: detected and documented, never installed or wrapped.
Before declaring a code change done
From the repo root. make check is the gate for what you changed (gofmt, vet host/windows/linux, tests of changed packages and dependents), not go test alone (Windows vet catches !windows-only helpers). make check-full runs all; CI is authoritative. make hooks once per clone runs these gates on commit and push (LEFTHOOK=0 skips one).
make checkAdapter smoke (requires downshift on PATH):
./examples/run-all.shClassifier or signal changes need a table-driven test in classifier_edge_test.go (or adjacent *_test.go). See CONTRIBUTING.md.
If you touched paths, HOME, symlinks, setup, wrappers or the exec layer, confirm
it is OS-agnostic: no /-hardcoded path, no $HOME, no POSIX-only wrapper on a
Windows path. The test-os CI job runs the OS-sensitive packages on
windows-latest and macos-latest — it must be green, not just the Linux
test job.
What NOT to do
- Do not remove copyright headers.
- Do not change the licence without explicit instruction from the Author.
- Do not add model IDs as hardcoded strings in Go source — use
catalog.json. - Do not write OS-specific paths or assumptions. Downshift ships on Windows,
Linux and macOS. Build paths with
filepath.Join/filepath.FromSlash(store/-separated, convert per-OS), resolve HOME withos.UserHomeDir()(neveros.Getenv("HOME")), and put any OS-specific behavior behind a build tag (_windows.go/_unix.go), asdetach_*.go,procgroup_*.goandinternal/paths/owned_*.goalready do. A/bin/shwrapper is POSIX-only: a harness install that must run on Windows needs a.cmd/.ps1sibling or a no-wrapper path. Setup must not auto-write a symlinked target (e.g.~/.kiro/steering→ a versioned repo);EvalSymlinksresolves it and behaves differently on Windows. - Do not commit the user override catalog in the repo (lives under
~/.downshift/). The embeddedinternal/catalog/catalog.jsonIS committed intentionally. - A model that must not be picked automatically gets
routing:"explicit_only"; never an automatic target. - Do not tag or release from an agent session unless the Author named the version; see release-policy.md.
- The project licence is Apache 2.0. Do not suggest relicensing to proprietary terms without explicit instruction from the Author.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

