openclaw-audit
Skill5 starsChanged 4 months agoMITView on GitHub
Trim an OpenClaw workspace's base system prompt. Measures what the always-injected workspace files (SOUL.md, AGENTS.md, IDENTITY.md, USER.md, MEMORY.md) cost per turn, then works through them section by section — cutting what the tools or codebase already say, moving durable conventions to Clawness ranked retrieval (.clawness/rules/) and one-line traps to .clawness/memory.md, and leaving load-bearing persona and identity where they are. Destructive and deliberate: run it when you have the session to spend.
In this repository17 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- openclaw/CLAUDE.mdCLAUDE.md
- addSkill
- audit-rulesSkill
- bootstrapSkill
- claude-mdSkill
- eval-setSkill
- messagingSkill
- perfSkill
- refreshSkill
- reviewSkill
- security-auditSkill
- statusSkill
- testSkill
- user-docsSkill
- vuln-huntSkill
- vuln-reportSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 10 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 46
Check first: is the openclaw/ adapter installed and are .clawness/rules/ and .clawness/memory.md reachable in this workspace?
- Distinctive: line 51
Only these move the number.
- Distinctive: line 69
AGENTS.mdis the file sub-agents inherit, alone: Every char there is paid by the main loop *and* every sub-agent spawn. - Very specific: line 80
Read each present workspace file (AGENTS.md, SOUL.md, IDENTITY.md, USER.md, MEMORY.md.
- Distinctive: line 124
Never delete from a workspace file until its replacement is proven to surface.
- Distinctive: line 127
Write the new file (or add the rule / memory line).
- Distinctive: line 135
Only then remove the section from the workspace file.
- Distinctive: line 138
If verification fails, put the section back and mark it STAY.
- Very specific: line 144
If anything moved to .clawness/rules/, run bash "$CLAW" lint — it rejects missing fields and vague phrasing, and a rule that fails lint …
- Very specific: line 159
Don't run this without the OpenClaw adapter and .clawness/ retrieval in place — there is no cheap destination otherwise.
- Distinctive: line 161
Don't start from a passing mention or your own initiative.
- Distinctive: line 162
Don't move something because it is long.
- Very specific: line 164
Don't relocate bulk into OpenClaw's own MEMORY.md.
- Distinctive: line 165
Don't rewrite a persona while relocating around it.
- Distinctive: line 168
Don't treat the docs-derived filenames, caps, or hook names as verified.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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
Trim an OpenClaw workspace prompt
OpenClaw assembles its system prompt fresh for every agent turn. Alongside the fixed
sections it manages (Tooling, Safety, Skills, Workspace, …), it injects the workspace's
own Markdown files in full, every turn: AGENTS.md, SOUL.md, IDENTITY.md,
USER.md, BOOTSTRAP.md (new workspaces only, self-deletes after first run), and
MEMORY.md when present. That injected block is the one part of the per-turn cost the
workspace owner controls — and the usual "landslide of noise per turn" complaint is it
growing unchecked. OpenClaw caps it at 20,000 chars per file and 60,000 total and
truncates past that with a terse notice, which is a worse outcome than trimming on
purpose: you don't choose what gets cut.
This skill is the remedy, the OpenClaw sibling of /clawness:claude-md. It is opt-in
work: you invoking it is the consent, because a good trim is destructive and takes a while.
Say this before starting. This reorganises files the user may care about a great deal (SOUL.md is the agent's personality), and it takes most of a session. Tell them: nothing is deleted until its replacement is verified, and they can stop after any single file. Then get an explicit go-ahead.
Filenames and limits below are from OpenClaw's public docs, not a live install. Before you measure, confirm the workspace path and the file set actually present — see the same caution in openclaw/README.md ("Assumptions to verify"). The default workspace is
~/.openclaw/workspace/; the user may point elsewhere.
First: is this the right tool?
This skill earns its place only when Clawness is running under OpenClaw (the openclaw/
TypeScript adapter shelling out to the Python hooks), because the whole point is to move
bulk out of always-injected files and into Clawness's ranked retrieval, which the
adapter provides via the before_prompt_build hook. Without that adapter installed there
is nowhere cheaper for the content to go, and you should stop and say so — trimming a
workspace file with no ranked destination just loses information.
Check first: is the openclaw/ adapter installed and are .clawness/rules/ and
.clawness/memory.md reachable in this workspace? If not, say what's missing and stop.
What actually reduces per-turn cost
Only these move the number. Get this right or the exercise is theatre:
| Destination | When it loads | Use for |
SOUL.md / IDENTITY.md / USER.md | every turn, in full | persona, identity, values, guardrails, user profile — load-bearing every turn |
AGENTS.md | every turn, in full — and it is the ONLY file sub-agent sessions get | core operating instructions; keep it the leanest of all |
OpenClaw MEMORY.md | every turn, in full | not a cheap destination — moving bulk here saves nothing |
.clawness/rules/*.yml | ranked per prompt, inside CLAW_BUDGET | durable conventions tied to a topic rather than the agent's identity |
.clawness/memory.md | ranked per prompt, ~3 lines | one-line traps that bit once |
| OpenClaw skills | when invoked or judged relevant | multi-step procedures |
Two OpenClaw-specific traps:
- OpenClaw's own
MEMORY.mdis injected whole, like the others. Do not "save cost" by shovelling material from SOUL.md into MEMORY.md — same per-turn tax, just relabelled. Durable conventions belong in.clawness/rules/(ranked); one-line traps in.clawness/memory.md(ranked). Only genuinely-every-turn curated memory stays in OpenClaw's MEMORY.md. AGENTS.mdis the file sub-agents inherit, alone. Every char there is paid by the main loop and every sub-agent spawn. It is the highest-leverage file to shrink and the one where "keep it operational, move the rest" matters most.
OpenClaw's own guidance echoes this: keep SOUL.md under ~500 words and AGENTS.md under
~300; adherence improves as they shrink, not worse.
Steps
1. Measure
Read each present workspace file (AGENTS.md, SOUL.md, IDENTITY.md, USER.md,
MEMORY.md; ignore BOOTSTRAP.md — it self-deletes). Report:
- per-file characters and a rough token estimate (chars ÷ 4; call it rough, it is), plus the total and how it sits against the 20k/file and 60k/total caps
- a per-section breakdown by top-level heading within each file, largest first
The breakdown is the point. "Your workspace is 8k tokens" invites a shrug; "your AGENTS.md Tooling section is 2.1k tokens re-describing tools OpenClaw already lists in its Tooling section, and every sub-agent pays for it too" does not.
If you can, measure the real assembled cost, not just the files. OpenClaw exposes the
fully assembled prompt (all fixed sections + injected files) through the llm_input and
before_agent_run hooks. A tiny observation-only plugin logging the assembled length once
gives the true per-turn number, of which the workspace files are only a part. Offer this;
mark it as docs-derived and unverified against a live host until you've run it.
2. Classify every section
Go heading by heading, per file, and assign one verdict. Default to STAY. The burden of proof is on moving something.
- STAY — persona, identity, values, behavioural guardrails, user profile, and core operating instructions. This is load-bearing every turn regardless of the prompt, which is exactly what retrieval cannot be trusted to surface on demand. SOUL.md's personality and USER.md's "call me X" must be present whether or not the prompt hints at them. Keep them — just tighten wording (see Don'ts: tighten is not reword-the-meaning).
- CUT — anything the tools, workspace, or codebase already answer: tool inventories (OpenClaw's Tooling section already lists them), restated OpenClaw docs, directory layouts, dependency lists, and history that reads as a changelog.
- →
.clawness/rules/<domain>/<ID>.yml— a durable convention tied to a topic rather than the agent's identity (coding standards, a library's house style, error-handling rules). Full rule format:id, domain, severity, tags, triggers, when, rule, violation, correct.tags/triggersdrive retrieval — put the words someone would actually type. - →
.clawness/memory.md— one-line traps only, under## Lessons, ≤120 chars, naming the file or flag so it retrieves. If the rationale is the payload, it is not a memory entry; use.clawness/rules/instead.
Present the whole classification as a table and get approval before moving anything. Include the projected per-turn token saving (and, if AGENTS.md shrinks, note the extra sub-agent saving separately).
3. Move one section at a time, verify, then delete
Never delete from a workspace file until its replacement is proven to surface. For each approved section, smallest first:
- Write the new file (or add the rule / memory line).
- Verify it:
.clawness/rules/→ confirm the new ID retrieves. TheclawnessCLI ships with the plugin but isn't on PATH; run it via the bundled launcher (or the bootstrap's wrapper on older Claude Code):CLAW="${CLAUDE_PLUGIN_ROOT}/scripts/clawness-cli.sh"; [ -f "$CLAW" ] || CLAW="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/clawness/clawness-cli.sh", thenbash "$CLAW" query "<a prompt this should match>"and check the ID appears. (Editable/manual installs may usepython -m clawness.cli query ....).clawness/memory.md→ the entry is one line under## Lessons.
- Only then remove the section from the workspace file.
- Say what moved and what the file is down to.
If verification fails, put the section back and mark it STAY. A rule that doesn't retrieve is strictly worse than a paragraph in SOUL.md.
4. Finish
- Re-measure and report the before/after per file and in total (and against the caps).
- If anything moved to
.clawness/rules/, runbash "$CLAW" lint— it rejects missing fields and vague phrasing, and a rule that fails lint won't survive CI in projects that gate on it. - Lock in the trade with an eval set. Moving content from an always-injected file into
ranked retrieval swaps a guarantee for a probability. Run
/clawness:eval-setto write a case for each thing the trimmed content used to guarantee and confirm hit-rate is 1.0 — that is the proof the move was safe, and it catches a later rule edit that stops surfacing. - Remind the user that OpenClaw re-reads workspace files each session, so the smaller prompt takes effect on the next agent run.
- Suggest committing the workspace files as one reviewable change (the moves can then be
read and reverted as a unit). Note that
SOUL.md/AGENTS.md/MEMORY.mdare usually committed, whileUSER.mdis often personal — respect the project's existing gitignore.
Don't
- Don't run this without the OpenClaw adapter and
.clawness/retrieval in place — there is no cheap destination otherwise. - Don't start from a passing mention or your own initiative. It is opt-in work.
- Don't move something because it is long. Move it because it is not identity — persona and user profile STAY however long, conventions and inventories move however short.
- Don't relocate bulk into OpenClaw's own
MEMORY.md; that is the same per-turn cost. - Don't rewrite a persona while relocating around it. Trim wording in a separate, visible pass if the user wants — a reorganisation that silently reworded SOUL.md is impossible to review, and SOUL.md is the one file where wording is the behaviour.
- Don't treat the docs-derived filenames, caps, or hook names as verified. Confirm the real workspace against a live OpenClaw before acting, and say which parts you couldn't check.
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.

