agentleFS
arminkarmink/FlashDB/AGENTS.md

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
  1. Very specific:

    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 …

    line 32
  2. Very specific:

    All flash access goes through fal_flash_*.

    line 54
  3. Very specific:

    Do not add heap allocation.

    line 55
  4. Distinctive:

    Do not change public API names or signatures without stating the compatibility impact first.

    line 59
  5. Very specific:

    When header layout changes, update the _TKV_* macros in the tests too, otherwise cases compute wrong addresses and pass silently.

    line 73
  6. Very specific:

    Before committing, make sure no case was left unregistered (missing UTEST_UNIT_RUN).

    line 75

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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:

  1. clones armink/FlashDBAutoTestBSP and armink/UtestRunner;
  2. copies src/*, tests/*, inc/fdb_def.h, inc/fdb_low_lvl.h and inc/flashdb.h into the BSP's packages/FlashDB/;
  3. cross-compiles with scons --global-macros="FDB_WRITE_GRAN=<n>";
  4. runs qemu_runner.py under QEMU and reads rtt_console.log for 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/*.c on an x86 host as verification: fdb_cfg.h has to be provided by the user, and many problems only appear at a specific granularity.

Layout

  • inc/ public headers, flashdb.h is the only entry point
  • src/ implementation, fdb_read_cache.c is the optional read cache
  • port/fal/ vendored third-party FAL, read-only, do not modify
  • tests/ utest cases
  • demos/ per-platform examples
  • docs/ English and Chinese documentation, must be updated when an API changes

Hard rules

  1. Every change ships with test closure. Touching src/ means touching tests/fdb_kvdb_tc.c or tests/fdb_tsdb_tc.c in the same commit, and registering the new case in the UTEST_UNIT_RUN(...) list of static 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 / pure docs/ / 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.
  2. C99 only: no C++, no C11 atomics, no compiler builtins.
  3. All flash access goes through fal_flash_*; never call the chip HAL directly.
  4. Do not add heap allocation. The only allocation point is src/fdb_read_cache.c, overridable via FDB_READ_CACHE_MALLOC / FDB_READ_CACHE_FREE.
  5. Feature code goes inside #ifdef FDB_USING_<FEATURE>; a new config macro must be added to inc/fdb_cfg_template.h with its valid range documented.
  6. Do not change public API names or signatures without stating the compatibility impact first.
  7. A KV/TSL node format change must bump the version and describe how old data migrates.
  8. New files keep the Apache-2.0 license header (copy an existing source file).
  9. Comment only where "why" needs explaining; do not restate the code. Source comments and commit messages are in English.

Definition of done

  1. 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.
  2. Power-loss related changes are verified with a fdb_xxx_deinit -> fdb_xxx_init reboot simulation.
  3. Cases never hard-code the write granularity; derive lengths with FDB_WG_ALIGN() / _TKV_W, because CI runs FDB_WRITE_GRAN = 1/8/32/64/128/256.
  4. When header layout changes, update the _TKV_* macros in the tests too, otherwise cases compute wrong addresses and pass silently.
  5. 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 changes

Format: 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.

Download now (ZIP)

  • 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.

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.