Inspiration

My Hermes memory filled up. I had a hard character budget for standing rules, and the rules I actually needed kept bumping against it. Worse: every stored rule was injected into every turn — I was paying tokens for a security-review rule while debugging a GPU driver.

The insight: storage and context are two different problems. The number of rules I keep should not bound the number of rules the model sees per job. So I decoupled them.

What it does

Standing-rules-database-skill is a SQLite-backed rules engine for AI coding agents. The database is the authoritative store; markdown views are generated from it, never hand-edited.

  • Tier 1 (small, always loaded): identity, hard bans, money rules — injected every turn.
  • Tier 2 (unbounded): everything else, each rule tagged with domain and output-type triggers. A pre_llm_call hook greps the incoming message against the trigger table and injects only the rules whose triggers fire.

Context cost per turn drops from

$$ C_{\text{naive}} = \sum_{i=1}^{N} \mathrm{len}(\mathrm{rule}_i) \quad\longrightarrow\quad C_{\text{matched}} = \sum_{i \in M} \mathrm{len}(\mathrm{rule}_i) $$

and the matching is fully deterministic — keyword triggers, no embeddings, no vector DB, no API call. My live database holds 42 rules (9 tier-1, 32 tier-2 across 16 task domains); a typical turn pays for the 9 plus the handful that match. The database can grow to hundreds of rules and per-turn cost stays flat, because it is bound by trigger matches, not database size.

Every rule carries a stable ID, a priority (which rule wins in a conflict), a domain, and a lifecycle status — nothing is ever deleted, only deprecated in place with a reason, and every write lands in an audit ledger. A write gate classifies candidates before they enter: standing constraint → rule; numbered procedure → task skill; one-off → not stored.

An optional enterprise layer (a FastAPI dashboard, live at rules.neuroplura.com) syncs org-managed rules to agent machines: multi-tenant Bearer-token sync, a persistent seat registry with admin-retirable machines, corporate-domain enforcement, HMAC-SHA256-signed rule payloads so a tampered ruleset fails an integrity check on the client, and fail-closed compliance — a client that cannot reach the master database within 24 hours freezes its org rules and tells the user to re-establish communications.

How we built it

Built with Hermes (the agent runtime the skill plugs into, via its hook system) and Kiro IDE — my first time using an IDE with an integrated AI. Kiro's specs and steering files are committed to the repo (.kiro/),so the development trail is part of the submission — including a Kiro agent hook that runs the full test suite automatically on every agent edit of a Python file

  • Core (public, MIT): stdlib-only Python — no dependencies, installs anywhere Python runs. SQLite store, query engine (query --match), audit ledger, CLI lifecycle commands, and generated markdown views.
  • Hook layer: a shell hook fires before each LLM call, queries the database with the incoming message, and injects the matched rules — the agent never has to remember to consult it.
  • Bootstrap tooling: the skill ships empty by design — a scanner reads an existing agent's memory files and proposes rule candidates as JSON, which the user reviews before anything activates. Your rules enter your system; none are shipped.
  • Enterprise layer (private repo, kept separate from the MIT core): FastAPI + SQLAlchemy dashboard with a Next.js admin UI, subscription webhooks, seat and domain enforcement, and the compliance controls described above.

Challenges we ran into

  • Learning to describe things to an AI so it actually gets what I want. The single biggest challenge of the whole project. I had to learn to specify outcomes, constraints, and acceptance criteria — not just vibes — and it took real iteration before "what I meant" and "what I asked for" lined up.
  • A silently failing security control. The seat-limit 403 never fired because the audit beacon was logged after the seat check. It taught me to distrust "it passed once" and to test the denial path, not just the happy path.
  • Test integrity. I caught myself faking headers and rows in tests — they passed, but they were testing a fiction. I rewrote them to route the real client's real HTTP calls through the real server endpoints. Rule adopted: never fake data that a real module should produce.
  • Testing a "success" that is a refusal. The fail-closed lockdown works by denying — which no test suite naturally expects, so the compliance paths needed deliberate, adversarial test design.

Accomplishments that we're proud of

  • 146 core tests and 55 dashboard tests passing, including real client↔server integration tests that drive the actual sync client against the actual API — no mocked data anywhere in that suite.
  • A live optional enterprise layer (private, outside the submitted repo) on top of a hobby skill: persistent seat registry, domain enforcement, HMAC-signed payloads, attestation hashing, and a three-stage delinquency workflow — deployed and serving live traffic.
  • The core stays radically portable: stdlib-only, MIT-licensed, 46 commits — the enterprise features never leaked into the public repo, so the open-source tool remains a clean 30-second install.
  • A keys scanner (rules_db.py keys plus a Tk window) that finds stray API keys in env vars, vaults, and files, verifies them against the server, reports only masked sightings, and can delete them surgically at the source — without a full key ever leaving the machine.
  • 42 real standing rules in daily use, with per-turn token cost flat as the database grows.

What we learned

  • Writing detailed prompts is a real skill. Most of the engineering was done by AI agents, and the quality of what came back was bounded almost entirely by how precisely I described the outcome and its acceptance criteria. Vague prompt, vague software.
  • Multiple AIs, each doing what it's good at. I used different models to draft and pressure-test prompts for the other ones — one writing a spec, another poking holes in it, a third executing it. Prompt generation itself became a multi-model workflow.
  • An AI-integrated IDE changes the loop. Kiro's specs and steering files meant project context was written down once and reused, instead of re-explained every session.
  • Storage ≠ context is the whole game. Most agent "memory" systems conflate the two. Separating them lets one agent hold hundreds of rules and pay for a handful per turn.
  • Deterministic beats clever. Keyword trigger matching: zero latency, zero API cost, no surprises.
  • Rule distribution is a distributed-systems problem. Revoking a rule is easy; proving the revocation reached the laptop is where seat registries, beacon hashing, and signature verification came from.

What's next for standing-rules-database-skill

  • Client-side attestation verification loop: the client already refuses tampered payloads; the next step is proving upward — signing tier-1 context attestation hashes back to the dashboard so admins see a per-machine compliance status.
  • Phrase and regex triggers alongside today's keyword matching, for higher-precision firing on longer rule sets.
  • One-command public onboarding: init + the candidate scanner already work; next is a guided first-run flow that imports rules from other agents' memory formats (Claude, Codex, Cursor) out of the box.
  • Postgres path for the dashboard (SQLite WAL today) and a compliance-reporting view that turns beacon and attestation data into an audit export enterprises can hand to their security team.

Built With

  • agent
  • agents
  • ai
  • cli
  • compliance
  • context
  • engine
  • engineering
  • hermes
  • kiro
  • llm
  • markdown
  • memory
  • open
  • optimization
  • prompt
  • python
  • rule
  • security
  • source
  • sqlite
  • tkinter
  • token
  • tools
Share this project:

Updates

posted an update —

This is a duplicate entry — I accidentally logged in with the wrong account and thought I had to remake the entire entry. The real submission is standing-rules-database-skill by NMBR5sgit, which has the demo URL, testing instructions, video, and all bonus answers. Please delete/hide this duplicate — thank you!

Submission history