Agent Guide
May 8, 2026 · View on GitHub
Read this file first. It tells you where to find context in this repo.
Quick Reference
| What you need | Where to look |
|---|---|
| How this repo is structured | ARCHITECTURE.md |
| How to build/test/run | CONTRIBUTING.md |
| Why decisions were made | docs/ADRs/ |
| What this repo does | README.md |
| PR review rules | .bito/guidelines/ |
| Active specs/work | docs/specs/ |
| Version migration guides | MIGRATION.md |
| Advanced usage patterns | ADVANCED.md |
| TypeScript usage | TYPESCRIPT.md |
Sharp Edges & Invariants
- Always run
npm run test:typesafter modifying types — type regressions are not caught by Vitest unit tests. Thetsdtype tests intest/types/are the only gate. - Always run
npm run checkafter changing build targets — es-check validates that output matches declared ES version targets (ES2017 for CJS/ESM, ES2018 for browser bundles). - Never modify the axios instance directly — HTTP configuration flows through
contentful-sdk-core'screateHttpClient. Custom headers go inCreateClientParams.headers. - Bundle size is CI-enforced —
size-limitchecks run in CI. If you add a dependency, verify it doesn't blow the 85KB (browser) / 45KB (min) limits vianpm run test:size. dist/esm-raw/is an intermediate build artifact — it's Rollup input, not a shipped output. Never import from it or reference it in package.json exports.- Link resolution happens in
contentful-resolve-response— not in this repo. If link resolution is broken, look there. - Content Source Maps only work with CPA —
includeContentSourceMaps: truerequireshost: 'preview.contentful.com'. It will not work with the CDA. __VERSION__is replaced at Rollup build time — it's defined inrollup.config.jsvia@rollup/plugin-replace. Don't reference it expecting a value at dev/test time without building first.
Key Conventions
- Commit format: Conventional Commits (enforced by commitizen + husky pre-commit hook)
- Branch strategy:
master(production, semantic-release on push) + feature branches, squash merge - Test location:
test/unit/,test/integration/,test/types/ - Module system: Dual ESM + CJS (source is ESM, Rollup produces CJS bundle)
- Import paths: Use
.jsextensions in TypeScript source imports (ESM convention) - Source lives in:
lib/(notsrc/) - Types live in:
lib/types/(shipped asdist/types/)
Integration Points
Upstream (this repo consumes):
contentful-sdk-core— HTTP client factory, rate limiting, retry, error normalizationcontentful-resolve-response— link resolution algorithm@contentful/content-source-maps— CSM encoding/decoding@contentful/rich-text-types— Rich Text type definitions- Contentful CDA/CPA HTTP APIs
Downstream (consumes this repo):
- Customer JavaScript/TypeScript applications
- Framework integrations (Next.js, Gatsby, Nuxt)
- Contentful Live Preview SDK
- Vercel Content Link
Build & Quality
# Quick verification loop
npm ci && npm run build && npm test && npm run check