extension-developmentlisted
Install: claude install-skill matejformanek/postgres-claude
# Building a PostgreSQL extension
Skill for shipping a loadable extension — what files to create, what each file
declares, the two supported build paths, and the hook/GUC idioms that 90% of
real extensions use.
Reference doc with a worked end-to-end example (pageinspect):
`knowledge/conventions/extension-layout.md`.
## 1. The minimum file set
For an extension named `<ext>` at version `1.0`:
```
<ext>.control # metadata read by CREATE EXTENSION
<ext>--1.0.sql # SQL objects installed by CREATE EXTENSION <ext>
<ext>.c # C code (if there is any)
Makefile # PGXS build
meson.build # only for in-tree contrib/ builds; out-of-tree
# extensions use PGXS (Makefile)
```
Add upgrade scripts as the version moves: `<ext>--1.0--1.1.sql`,
`<ext>--1.1--1.2.sql`, … `ALTER EXTENSION <ext> UPDATE` chains them.
### `<ext>.control`
Real example, verbatim from `source/contrib/pageinspect/pageinspect.control`
[verified-by-code]:
```
# pageinspect extension
comment = 'inspect the contents of database pages at a low level'
default_version = '1.13'
module_pathname = '$libdir/pageinspect'
relocatable = true
```
Common fields (see `source/doc/src/sgml/extend.sgml` §"Extension Files"
[from-doc]):
- `default_version` — version installed when `CREATE EXTENSION` omits `VERSION`.
- `module_pathname` — substituted for `MODULE_PATHNAME` in the SQL scripts.
- `relocatable = true` — objects can be moved with `ALTER EXTENSION