|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +## Purpose |
| 4 | + |
| 5 | +This is a working guide for contributors and coding agents in this repository. |
| 6 | +It captures practical rules that prevent avoidable CI and PR churn. |
| 7 | + |
| 8 | +## Instruction precedence |
| 9 | + |
| 10 | +- Repository-specific instructions in this file override generic coding-agent defaults, skills, and templates. |
| 11 | +- If a generic workflow conflicts with this file, follow this file. |
| 12 | + |
| 13 | +## Repository Layout |
| 14 | + |
| 15 | +- This repository is an npm workspaces monorepo. |
| 16 | + - root package: `testcontainers-monorepo` |
| 17 | + - workspaces: `packages/testcontainers` and `packages/modules/*` |
| 18 | + - shared lockfile: root `package-lock.json` (workspace installs update this single file) |
| 19 | +- For workspace-scoped dependency changes, prefer targeted commands to reduce lockfile churn: |
| 20 | + - `npm install -w @testcontainers/<module>` |
| 21 | + - `npm uninstall -w @testcontainers/<module> <package>` |
| 22 | + |
| 23 | +## Development Expectations |
| 24 | + |
| 25 | +- If a public API changes, update the relevant docs in the same PR. |
| 26 | +- If new types are made part of the public API, export them from the package's `index.ts` in the same PR. |
| 27 | +- If new learnings or misunderstandings are discovered, propose an `AGENTS.md` update in the same PR. |
| 28 | +- In docs Markdown, keep `<!--codeinclude-->` blocks tight with no blank lines between the markers and the include line, or the rendered snippet will contain blank lines between code lines. |
| 29 | +- Tests should verify observable behavior changes, not only internal/config state. |
| 30 | + - Example: for a security option, assert a real secure/insecure behavior difference. |
| 31 | +- Test-only helper files under `src` (for example `*-test-utils.ts`) must be explicitly excluded from package `tsconfig.build.json` so they are not emitted into `build` and accidentally published. |
| 32 | +- Vitest runs tests concurrently by default (`sequence.concurrent: true` in `vitest.config.ts`). |
| 33 | + - Tests that rely on shared/global mocks (for example `vi.spyOn` on shared loggers/singletons) can be flaky due to interleaving or automatic mock resets. |
| 34 | + - Prefer asserting observable behavior instead of shared global mock state when possible. |
| 35 | + - If a test must depend on shared/global mock state, use `it.sequential(...)` or `describe.sequential(...)`. |
| 36 | + |
| 37 | +## Permission and Escalation |
| 38 | + |
| 39 | +- `npm install` requires escalated permissions for outbound network access to npm registries. |
| 40 | +- `npm test` commands should be run with escalation so tests can access the Docker socket. |
| 41 | + |
| 42 | +### Escalation hygiene |
| 43 | + |
| 44 | +- Use specific commands and clear justifications. |
| 45 | +- Prefer narrow reruns rather than broad full-suite reruns when iterating. |
| 46 | + |
| 47 | +## PR Process |
| 48 | + |
| 49 | +1. Start from `main`. |
| 50 | +2. Create a branch prefixed with `codex/`. |
| 51 | +3. Implement scoped changes only. |
| 52 | +4. Run required checks: `npm run format`, `npm run lint`, and targeted tests. |
| 53 | +5. Verify git diff only contains intended files. |
| 54 | +6. Never commit, push, or post on GitHub (issues, PRs, or comments) without first sharing the proposed diff/message and getting explicit user approval. |
| 55 | +7. Commit with focused message(s), using `git commit --no-verify`. |
| 56 | + - Never bypass signing (for example, do not use `--no-gpg-sign`). |
| 57 | + - If signing fails (for example, passphrase/key issues), stop and ask the user to resolve signing, then retry. |
| 58 | +8. Push branch. Ask for explicit user permission before any force push. |
| 59 | +9. Open PR against `main` using a human-readable title (no `feat(...)` / `fix(...)` prefixes, and no agent-identifying prefixes or suffixes). |
| 60 | + - Default to a ready-for-review PR. Only open or keep a PR in draft when the user explicitly asks for a draft. |
| 61 | + - When using `gh` to create/edit PR descriptions, prefer `--body-file <path>` over inline `--body`; this avoids shell command substitution issues when the body contains backticks. |
| 62 | +10. Add labels for both change type and semantic version impact. |
| 63 | +11. Ensure PR body includes: |
| 64 | + - summary of changes |
| 65 | + - verification commands run |
| 66 | + - test results summary |
| 67 | + - if semver impact is not `major`, evidence that the change is not breaking |
| 68 | + - `Closes #<issue>` only when the PR is intended to close a specific issue |
| 69 | + |
| 70 | +## Labels |
| 71 | + |
| 72 | +### Change type |
| 73 | + |
| 74 | +- `enhancement` |
| 75 | +- `bug` |
| 76 | +- `dependencies` |
| 77 | +- `documentation` |
| 78 | +- `maintenance` |
| 79 | + |
| 80 | +### Semver impact |
| 81 | + |
| 82 | +- `major` |
| 83 | +- `minor` |
| 84 | +- `patch` |
| 85 | + |
| 86 | +### Common mappings |
| 87 | + |
| 88 | +- backward-compatible feature: `enhancement` + `minor` |
| 89 | +- backward-compatible bug fix: `bug` + `patch` |
| 90 | +- breaking change: type label + `major` |
| 91 | +- docs-only change: `documentation` + usually `patch` |
| 92 | +- dependency update: `dependencies` + impact label based on user-facing effect |
| 93 | + |
| 94 | +## Lockfile Hygiene |
| 95 | + |
| 96 | +- Recheck `package-lock.json` after `npm install` for unrelated drift and revert unrelated changes. |
0 commit comments