FlashDB
AGENTS.md2.9k starsChanged 8 months agoApache-2.0View on GitHub
Instructions for AI coding agents working in this repository (Copilot coding agent, Claude Code, Codex, ...). Review-specific checks live in .github/copilot-instructions.md. FlashDB is an ultra-lightweight embedded database for MCUs, plain C99, relying on FAL (Flash Abstraction Layer) to reach flash. It provides KVDB (key/value) and TSDB (time series) on top of raw flash or a file. This repository cannot be built on its own: src/ and inc/ are library sources and the tests need an external BSP project. CI (.github/workflows/main.yml)…
We split this AGENTS.md into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are 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.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
do not treat compiling src/*.c on an x86 host as verification: fdb_cfg.h has to be provided by the user, and many problems only appear at a …
- Very specific: line 54
All flash access goes through fal_flash_*.
- Very specific: line 55
Do not add heap allocation.
- Distinctive: line 59
Do not change public API names or signatures without stating the compatibility impact first.
- Very specific: line 73
When header layout changes, update the _TKV_* macros in the tests too, otherwise cases compute wrong addresses and pass silently.
- Very specific: line 75
Before committing, make sure no case was left unregistered (missing UTEST_UNIT_RUN).
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 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
AGENTS.md
Instructions for AI coding agents working in this repository (Copilot coding agent,
Claude Code, Codex, ...). Review-specific checks live in .github/copilot-instructions.md.
What this project is
FlashDB is an ultra-lightweight embedded database for MCUs, plain C99, relying on FAL (Flash Abstraction Layer) to reach flash. It provides KVDB (key/value) and TSDB (time series) on top of raw flash or a file.
Environment and verification
This repository cannot be built on its own: src/ and inc/ are library sources and
the tests need an external BSP project.
CI (.github/workflows/main.yml) does the following:
- clones
armink/FlashDBAutoTestBSPandarmink/UtestRunner; - copies
src/*,tests/*,inc/fdb_def.h,inc/fdb_low_lvl.handinc/flashdb.hinto the BSP'spackages/FlashDB/; - cross-compiles with
scons --global-macros="FDB_WRITE_GRAN=<n>"; - runs
qemu_runner.pyunder QEMU and readsrtt_console.logfor the result.
FDB_WRITE_GRAN takes 1, 8, 32, 64, 128, 256; CI covers all of them.
So:
- with network and scons available, reproduce CI locally with the steps above;
- without that environment, do not claim tests passed; state "not verified" and say which granularities still need a run;
- do not treat compiling
src/*.con an x86 host as verification:fdb_cfg.hhas to be provided by the user, and many problems only appear at a specific granularity.
Layout
inc/public headers,flashdb.his the only entry pointsrc/implementation,fdb_read_cache.cis the optional read cacheport/fal/vendored third-party FAL, read-only, do not modifytests/utest casesdemos/per-platform examplesdocs/English and Chinese documentation, must be updated when an API changes
Hard rules
- Every change ships with test closure. Touching
src/means touchingtests/fdb_kvdb_tc.cortests/fdb_tsdb_tc.cin the same commit, and registering the new case in theUTEST_UNIT_RUN(...)list ofstatic void testcase(void). For a bug fix, write the failing case first (its name carries the issue number, e.g.test_fdb_github_issue_249), then change the implementation. Pure comment / puredocs// pure formatting changes are exempt, but explain why behaviour is unaffected; a pure refactor may skip new cases but must name the existing ones that cover it. - C99 only: no C++, no C11 atomics, no compiler builtins.
- All flash access goes through
fal_flash_*; never call the chip HAL directly. - Do not add heap allocation. The only allocation point is
src/fdb_read_cache.c, overridable viaFDB_READ_CACHE_MALLOC/FDB_READ_CACHE_FREE. - Feature code goes inside
#ifdef FDB_USING_<FEATURE>; a new config macro must be added toinc/fdb_cfg_template.hwith its valid range documented. - Do not change public API names or signatures without stating the compatibility impact first.
- A KV/TSL node format change must bump the version and describe how old data migrates.
- New files keep the Apache-2.0 license header (copy an existing source file).
- Comment only where "why" needs explaining; do not restate the code. Source comments and commit messages are in English.
Definition of done
- The case covers the changed behaviour and its boundaries: sector full, KV nodes full triggering GC, blob length crossing the write granularity, TSDB full, init check failure.
- Power-loss related changes are verified with a
fdb_xxx_deinit->fdb_xxx_initreboot simulation. - Cases never hard-code the write granularity; derive lengths with
FDB_WG_ALIGN()/_TKV_W, because CI runsFDB_WRITE_GRAN= 1/8/32/64/128/256. - When header layout changes, update the
_TKV_*macros in the tests too, otherwise cases compute wrong addresses and pass silently. - Before committing, make sure no case was left unregistered (missing
UTEST_UNIT_RUN).
Code style
4-space indent, no tabs, Allman braces; fdb_xxx public, _fdb_xxx cross-file internal,
static for file-local. See .github/copilot-instructions.md.
Commit messages
Conventional Commits, following existing history:
feat(kvdb): add a transient sector read cache for the loading phases (#433)
fix(tsdb): fix deadlock when not-format init check fails (#427)
docs: sync the docs with the recent code changesFormat: type(scope): lowercase imperative description, scope usually kvdb, tsdb, fal,
docs or test. One commit does one thing; do not reformat untouched code along the way.
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 28,693 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 repositoryOne other file it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
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.

