agentleFS
AWSKnown publisheraws/pgcollection/AGENTS.md

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

    If pg_config is not on PATH, point at a specific server:

    line 32
  2. Very specific:

    Instead add a new sql/collection--Y--Z.sql and bump the version.

    line 64

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

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

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 the icollection_*.c counterparts.
  • include/ headers, including the shared collection.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 installcheck

If pg_config is not on PATH, point at a specific server:

make PG_CONFIG=/path/to/pg/bin/pg_config install

The 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: EXTVERSION in the Makefile, collection.control.in, and META.json.in.
  • Released migration scripts are frozen. Never edit a sql/collection--X--Y.sql that has shipped; a database that already applied it will not re-run it. Instead add a new sql/collection--Y--Z.sql and bump the version.
  • The current in-development version can still be edited freely until it is tagged. Check git tag to see what has actually been released; the highest tag is the last shipped version, and default_version in 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:

  1. The C implementation in src/ (and its twin, if the other type applies).
  2. The SQL declaration in the appropriate migration script.
  3. A COMMENT ON entry 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.
  4. An entry in doc/functions.md.
  5. A regression test in test/sql/ with expected output in test/expected/.

Download now (ZIP)

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.