pgcollection
AGENTS.md24 starsChanged 2 years agoApache-2.0View on GitHub
Guidance for AI agents (and new contributors) working on the pgcollection source. For what the extension does and how to use it, read README.md and doc/. This file covers how to change it safely. A PostgreSQL extension written in C (PGXS build) that provides two in-memory associative array types for PL/pgSQL: collection (text keys) and icollection (bigint keys). Requires PostgreSQL 14 or later. - src/ C implementation. Files are split by type and concern, e.g. collection.c, collection_io.c, collection_userfuncs.c, collection_subs.c, collection_parse.c,…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 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.
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
If pg_config is not on PATH, point at a specific server:
- Very specific: line 64
Instead add a new sql/collection--Y--Z.sql and bump the version.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 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
Guidance for AI agents (and new contributors) working on the pgcollection
source. For what the extension does and how to use it, read README.md and
doc/. This file covers how to change it safely.
What this is
A PostgreSQL extension written in C (PGXS build) that provides two in-memory
associative array types for PL/pgSQL: collection (text keys) and
icollection (bigint keys). Requires PostgreSQL 14 or later.
Layout
src/C implementation. Files are split by type and concern, e.g.collection.c,collection_io.c,collection_userfuncs.c,collection_subs.c,collection_parse.c, and theicollection_*.ccounterparts.include/headers, including the sharedcollection.h.sql/extension install and upgrade scripts (collection--X--Y.sql).test/sql/regression inputs,test/expected/their expected output.doc/user-facing documentation.
Build and test
make
make install
make installcheckIf pg_config is not on PATH, point at a specific server:
make PG_CONFIG=/path/to/pg/bin/pg_config installThe regression suite is the REGRESS list in the Makefile. When behavior
changes, update the matching file in test/expected/ (or regenerate it) so
installcheck passes.
Code style
C code must pass pgindent with the upstream typedefs.list; CI fails on any
diff (see .github/workflows/test.yml). include/uthash/uthash.h is excluded
via tools/pgindent_excludes. Match the surrounding style, prefer psprintf
over manual palloc + sprintf.
The two types mirror each other
Almost every feature exists twice: once for collection (text keys, src/collection*.c)
and once for icollection (bigint keys, src/icollection*.c), with parallel
SQL declarations. A change to one type almost always needs the same change to
its twin. Check both before considering a change complete.
Versioning and migrations
This is the easiest thing to get wrong.
- The version lives in three places that must stay in sync:
EXTVERSIONin theMakefile,collection.control.in, andMETA.json.in. - Released migration scripts are frozen. Never edit a
sql/collection--X--Y.sqlthat has shipped; a database that already applied it will not re-run it. Instead add a newsql/collection--Y--Z.sqland bump the version. - The current in-development version can still be edited freely until it is
tagged. Check
git tagto see what has actually been released; the highest tag is the last shipped version, anddefault_versionin the control file may already point past it at the unreleased work in progress.
Adding or changing a SQL-visible function
A change is not complete until all of these agree:
- The C implementation in
src/(and its twin, if the other type applies). - The SQL declaration in the appropriate migration script.
- A
COMMENT ONentry in the same migration. Every extension object carries a terse catalog comment so an installed database is self-describing; do not leave a new function blank. - An entry in
doc/functions.md. - A regression test in
test/sql/with expected output intest/expected/.
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.

