awb-config-guard
Skill2 starsChanged 6 months agoMITView on GitHub
WHAT: guard against the two silent failures of config access — reading a key in the wrong CONTEXT, and reading a nested key at the wrong LEVEL (which returns None silently). USE WHEN: writing or modifying code that reads/writes configuration — especially a nested key, or a read that runs in more than one execution context (in-request vs. a script/job). DO NOT TRIGGER: reading config once just to understand the system; a single hard-coded constant with no nesting and one obvious context.
In this repository21 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- awb-cookSkill
- awb-dead-code-auditSkill
- awb-debugSkill
- awb-external-refSkill
- awb-handoverSkill
- awb-install-and-verifySkill
- awb-lessons-captureSkill
- awb-optimizeSkill
- awb-output-guardSkill
- awb-plan-then-codeSkill
- awb-researchSkill
- awb-reviewSkill
- awb-session-closeSkill
- awb-stress-testSkill
- awb-tddSkill
- awb-uninstallSkill
- awb-using-skillsSkill
- awb-verify-docsSkill
- prompt-refinerSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
If either is unclear, stop and read the two sections below before writing code.
- Very specific: line 50
Always pair a nested read with or {} / or [] / or "" so a not-yet-seeded container can't raise downstream.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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
Config guard — two contexts, two levels
Announce on activation: "Using awb-config-guard — checking access context and key level."
Config bugs are quiet. The code runs, returns None or reads a stale value, and the failure
surfaces somewhere far away — an AttributeError on None, a per-request file read that drags
latency, a setting that silently never takes effect. The cheapest place to stop that is before you
write the access.
HARD GATE — verify BOTH before writing config-access code
- Context — where does this code run? Many apps expose config through two doors: an
in-request accessor (cached, valid only inside a framework request) and an out-of-band loader
(
load_config(path)for scripts, jobs, init). Use the wrong one and you get a runtime error ("working outside of application context") or a file read on every request. - Level — is the key top-level or nested under a container? A nested key read one
level deep returns
Nonesilently — no exception, just wrong behavior downstream.
If either is unclear, stop and read the two sections below before writing code.
Two contexts — don't cross them
| Accessor | Use when |
the in-request accessor (e.g. get_cfg()) | inside a framework request (routes, request-scoped services) |
the out-of-band loader (e.g. load_config(path)) | outside the framework (scripts, batch jobs, init) |
Two levels — the silent-None trap
A key under a container must be read two levels deep, with a typed fallback:
cfg.get("config_section", {}).get("inner_value") or {} # correct
cfg.get("inner_value") # BUG: returns None silentlyAlways pair a nested read with or {} / or [] / or "" so a not-yet-seeded container can't
raise downstream. Some settings live in the framework's own config object, not the config file —
changing them in the file does nothing. Confirm which surface owns a key before editing it.
Checklist before you commit a config change
- Top-level or nested? Nested → two-level read with a typed fallback.
- In-request context → in-request accessor; out-of-band → the loader.
- Framework-owned setting → change it on that surface, not the config file.
- Grep your diff for a flat read of a known-nested key — expect zero.
Failure-modes registry (append-only)
Each time a config access causes a new failure, add a row. Never delete a row — the table is collective memory of every way this has bitten before.
| # | Trigger | Symptom | Fix | Severity |
| 1 | nested key read flat | silent None → AttributeError far downstream | two-level read + or {} | high |
| 2 | out-of-band loader inside a request | file I/O every request (latency) | in-request accessor | medium |
| 3 | framework-owned setting put in the config file | setting silently never applies | set it on the framework surface | medium |
Honest limit
This skill is the advisory layer; it does not itself guarantee anything — it is
model-invoked and bypassable. The deterministic guarantee is the config-flat-access check in
tools/invariants.py, which always fires on a flat read of a
known-nested key (wire your real container + key names into it). Per
docs/guard-mechanisms.md, that invariant is authoritative;
this skill only explains the discipline behind it. It cannot detect a wrong-context read
statically (that depends on the call path), and the invariant is a line scan that needs its keys
configured — neither replaces reading the access site.
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.

