agents-md-kit 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +162 -2
- package/bin/agent-kit.js +6 -0
- package/core/files/.claude/settings.json +16 -0
- package/core/files/.claude/skills/agent-memory-protocol/SKILL.md +117 -0
- package/core/files/.claude/skills/api-design-rest/SKILL.md +126 -0
- package/core/files/.claude/skills/backend-architecture-principles/SKILL.md +116 -0
- package/core/files/.claude/skills/backend-security/SKILL.md +117 -0
- package/core/files/.claude/skills/changelog-and-versioning/SKILL.md +169 -0
- package/core/files/.claude/skills/database-best-practices/SKILL.md +104 -0
- package/core/files/.claude/skills/git-commit-and-workflow/SKILL.md +140 -0
- package/core/files/.claude/skills/project-management-workflow/SKILL.md +181 -0
- package/core/files/CLAUDE.md +1 -0
- package/core/files/MEMORY.md +77 -0
- package/core/files/docs/adr/0000-template.md +21 -0
- package/core/fragments/agents-core.md +61 -0
- package/core/manifest.txt +21 -0
- package/docs/monorepo.md +72 -0
- package/package.json +50 -4
- package/packs/github/files/.github/ISSUE_TEMPLATE/bug_report.md +22 -0
- package/packs/github/files/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/packs/github/files/.github/pull_request_template.md +24 -0
- package/packs/github/files/.github/workflows/pr-title.yml +37 -0
- package/packs/github/manifest.txt +6 -0
- package/packs/web/files/.claude/skills/html-syntax-and-semantics/SKILL.md +127 -0
- package/packs/web/files/.claude/skills/seo-best-practices/SKILL.md +158 -0
- package/packs/web/fragments/agents-web.md +11 -0
- package/packs/web/manifest.txt +5 -0
- package/presets/node-backend/docs/node-backend.md +60 -0
- package/presets/node-backend/files/.editorconfig +12 -0
- package/presets/node-backend/files/.husky/commit-msg +1 -0
- package/presets/node-backend/files/.husky/pre-commit +1 -0
- package/presets/node-backend/files/.lintstagedrc.json +4 -0
- package/presets/node-backend/files/.prettierrc.json +7 -0
- package/presets/node-backend/files/.release-please-manifest.json +3 -0
- package/presets/node-backend/files/CHANGELOG.md +5 -0
- package/presets/node-backend/files/commitlint.config.mjs +12 -0
- package/presets/node-backend/files/eslint.config.mjs +38 -0
- package/presets/node-backend/files/release-please-config.json +25 -0
- package/presets/node-backend/fragments/agents-node-backend-github.md +7 -0
- package/presets/node-backend/fragments/agents-node-backend.md +13 -0
- package/presets/node-backend/fragments/gitignore.txt +19 -0
- package/presets/node-backend/fragments/prettierignore.txt +16 -0
- package/presets/node-backend/github/dependabot.yml +21 -0
- package/presets/node-backend/github/workflows/ci.yml +38 -0
- package/presets/node-backend/github/workflows/release-please.yml +21 -0
- package/presets/node-backend/manifest.txt +30 -0
- package/presets/python/docs/python.md +66 -0
- package/presets/python/files/.editorconfig +15 -0
- package/presets/python/files/.pre-commit-config.yaml +32 -0
- package/presets/python/files/.release-please-manifest.json +3 -0
- package/presets/python/files/CHANGELOG.md +5 -0
- package/presets/python/files/mypy.ini +5 -0
- package/presets/python/files/pytest.ini +6 -0
- package/presets/python/files/release-please-config.json +25 -0
- package/presets/python/files/ruff.toml +17 -0
- package/presets/python/fragments/agents-python-github.md +7 -0
- package/presets/python/fragments/agents-python.md +14 -0
- package/presets/python/fragments/gitignore.txt +25 -0
- package/presets/python/github/dependabot.yml +18 -0
- package/presets/python/github/workflows/ci.yml +37 -0
- package/presets/python/github/workflows/release-please.yml +21 -0
- package/presets/python/manifest.txt +25 -0
- package/presets/react-typescript/docs/react-typescript.md +71 -0
- package/presets/react-typescript/files/.claude/skills/react-principles/SKILL.md +264 -0
- package/presets/react-typescript/files/.editorconfig +12 -0
- package/presets/react-typescript/files/.husky/commit-msg +1 -0
- package/presets/react-typescript/files/.husky/pre-commit +1 -0
- package/presets/react-typescript/files/.lintstagedrc.json +4 -0
- package/presets/react-typescript/files/.prettierrc.json +7 -0
- package/presets/react-typescript/files/.release-please-manifest.json +3 -0
- package/presets/react-typescript/files/CHANGELOG.md +5 -0
- package/presets/react-typescript/files/commitlint.config.mjs +12 -0
- package/presets/react-typescript/files/eslint.config.mjs +55 -0
- package/presets/react-typescript/files/release-please-config.json +25 -0
- package/presets/react-typescript/fragments/agents-react-typescript-github.md +7 -0
- package/presets/react-typescript/fragments/agents-react-typescript.md +17 -0
- package/presets/react-typescript/fragments/gitignore.txt +22 -0
- package/presets/react-typescript/fragments/prettierignore.txt +17 -0
- package/presets/react-typescript/github/dependabot.yml +21 -0
- package/presets/react-typescript/github/workflows/ci.yml +38 -0
- package/presets/react-typescript/github/workflows/release-please.yml +21 -0
- package/presets/react-typescript/manifest.txt +32 -0
- package/src/blocks.js +132 -0
- package/src/cli.js +159 -0
- package/src/fsutil.js +123 -0
- package/src/install.js +223 -0
- package/src/manifest.js +187 -0
- package/src/validate.js +324 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: backend-security
|
|
3
|
+
description: Security rules for backend and full-stack web applications, based on OWASP guidance. Use when implementing authentication, authorization, sessions/tokens, input handling, file uploads, secrets, headers, CORS, dependencies, or when reviewing code for vulnerabilities.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Backend and Web Security Rules
|
|
7
|
+
|
|
8
|
+
Security is a requirement of every feature, not a later phase. Apply defense in depth and least privilege. Reference: OWASP Top 10 and the OWASP ASVS / Cheat Sheet Series.
|
|
9
|
+
|
|
10
|
+
## 1. Authentication
|
|
11
|
+
|
|
12
|
+
- Don't build your own crypto or auth protocols. Use a vetted library, framework feature or identity provider (OIDC/OAuth 2.1, Auth0, Cognito, Keycloak, etc.).
|
|
13
|
+
- Hash passwords with **Argon2id** (or scrypt/bcrypt as fallback) using a unique salt and tuned cost. Never MD5/SHA-1/plain SHA-256 for passwords.
|
|
14
|
+
- Enforce reasonable password policy: minimum length (12+ recommended), allow long passphrases and paste, check against breached-password lists. Don't force arbitrary complexity or periodic rotation.
|
|
15
|
+
- Offer MFA (TOTP, WebAuthn/passkeys). Require it for admin and sensitive actions.
|
|
16
|
+
- Rate-limit and lock out/slow down repeated failed logins. Return identical messages for unknown user vs wrong password.
|
|
17
|
+
- Password reset: single-use, short-lived, high-entropy tokens stored hashed. Don't reveal whether an email exists. Invalidate sessions after a password change.
|
|
18
|
+
|
|
19
|
+
## 2. Sessions and Tokens
|
|
20
|
+
|
|
21
|
+
- Session cookies: `HttpOnly; Secure; SameSite=Lax` (or `Strict`), with a sensible `Path`/`Domain`, and the `__Host-` prefix where possible. Regenerate the session ID on login and privilege change. Expire on idle and absolute timeouts, and invalidate on logout server-side.
|
|
22
|
+
- JWTs: use short-lived access tokens, validate signature, `iss`, `aud`, `exp`, and the algorithm allowlist (never accept `alg: none`). Use refresh-token rotation with revocation/reuse detection. Don't put sensitive data in the payload (it's only encoded, not encrypted).
|
|
23
|
+
- Don't store tokens in `localStorage` for browser apps if avoidable (XSS-exposed). Prefer HttpOnly cookies.
|
|
24
|
+
- CSRF: with cookie-based auth, use `SameSite` plus anti-CSRF tokens (or double-submit/Origin checks) on state-changing requests.
|
|
25
|
+
|
|
26
|
+
## 3. Authorization (Most Common Failure: Broken Access Control)
|
|
27
|
+
|
|
28
|
+
- Deny by default. Enforce authorization **on the server, on every request**, for every resource. Hiding UI elements is not security.
|
|
29
|
+
- Check ownership/permissions of the specific object (prevent IDOR): `WHERE id = ? AND owner_id = currentUser`.
|
|
30
|
+
- Centralize policy (RBAC/ABAC/policy engine) instead of scattered `if` checks. Test permission rules explicitly.
|
|
31
|
+
- Apply least privilege to users, service accounts, API keys and DB credentials.
|
|
32
|
+
- Protect against mass assignment: bind only allowlisted fields. Never let clients set `role`, `isAdmin`, `ownerId`, etc.
|
|
33
|
+
- Multi-tenant apps: scope every query by tenant (consider row-level security).
|
|
34
|
+
|
|
35
|
+
## 4. Injection and Input Handling
|
|
36
|
+
|
|
37
|
+
- **SQL:** always use parameterized queries/prepared statements or an ORM's safe APIs. Never concatenate user input into SQL. Whitelist dynamic identifiers (column names, sort fields).
|
|
38
|
+
- **NoSQL/ORM operators, LDAP, OS commands, templates, XPath:** treat all as injection sinks. Avoid shelling out. If necessary, use argument arrays, never string commands.
|
|
39
|
+
- **XSS:** encode/escape output by context (HTML, attribute, JS, URL). Frameworks like React escape by default, so avoid `dangerouslySetInnerHTML`, and sanitize with a vetted library (DOMPurify) if HTML must be rendered.
|
|
40
|
+
- **SSRF:** when fetching user-supplied URLs, allowlist hosts/schemes, block private/link-local/metadata IP ranges (e.g. `169.254.169.254`), re-validate after DNS resolution and redirects.
|
|
41
|
+
- **Path traversal:** never build file paths from user input directly. Normalize and confine to a base directory, or use generated IDs.
|
|
42
|
+
- **Deserialization:** don't deserialize untrusted data with native object serializers (pickle, Java serialization). Use plain JSON with schema validation.
|
|
43
|
+
- **Open redirects:** allowlist redirect targets.
|
|
44
|
+
- **XXE:** disable external entity processing in XML parsers.
|
|
45
|
+
|
|
46
|
+
## 5. File Uploads
|
|
47
|
+
|
|
48
|
+
- Enforce size limits, allowed extensions **and** verify content type by magic bytes. Don't trust the client's `Content-Type` or filename.
|
|
49
|
+
- Store outside the web root or in object storage. Rename to random IDs. Serve with `Content-Disposition` and a safe type, ideally from a separate domain.
|
|
50
|
+
- Scan for malware when appropriate. Re-encode images to strip payloads/metadata. Never execute uploaded files.
|
|
51
|
+
|
|
52
|
+
## 6. Secrets and Data Protection
|
|
53
|
+
|
|
54
|
+
- No secrets in source control, logs, error messages, URLs or client bundles. Use a secrets manager. Rotate secrets. Scan commits for leaks (gitleaks, GitHub secret scanning). Anything shipped to the browser is public.
|
|
55
|
+
- TLS 1.2+ everywhere (internal traffic too). Enable HSTS.
|
|
56
|
+
- Encrypt sensitive data at rest (disk/DB encryption, field-level for highly sensitive data), with managed keys (KMS).
|
|
57
|
+
- Collect and retain the minimum personal data. Support deletion/export (GDPR/LGPD obligations where applicable). Mask or tokenize payment data. Prefer a PCI-compliant provider so card data never touches your servers.
|
|
58
|
+
- Don't log personal data or secrets. Redact.
|
|
59
|
+
|
|
60
|
+
## 7. HTTP Security Headers
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
|
|
64
|
+
Content-Security-Policy: default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'
|
|
65
|
+
X-Content-Type-Options: nosniff
|
|
66
|
+
Referrer-Policy: strict-origin-when-cross-origin
|
|
67
|
+
Permissions-Policy: camera=(), microphone=(), geolocation=()
|
|
68
|
+
Cross-Origin-Opener-Policy: same-origin
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- Roll out CSP in report-only mode first, and prefer nonces/hashes over `'unsafe-inline'`.
|
|
72
|
+
- Use `frame-ancestors` (or `X-Frame-Options`) to prevent clickjacking.
|
|
73
|
+
- Remove version-revealing headers (`Server`, `X-Powered-By`).
|
|
74
|
+
- Cache-control `no-store` on sensitive responses.
|
|
75
|
+
|
|
76
|
+
## 8. CORS
|
|
77
|
+
|
|
78
|
+
- Allowlist specific origins. Never reflect arbitrary `Origin`, and never use `Access-Control-Allow-Origin: *` with credentials.
|
|
79
|
+
- Restrict allowed methods and headers to what is needed. CORS is a browser rule, not an authorization mechanism.
|
|
80
|
+
|
|
81
|
+
## 9. Rate Limiting and Abuse Prevention
|
|
82
|
+
|
|
83
|
+
- Apply rate limits per IP/user/API key, with stricter limits on auth, password reset, OTP, search and expensive endpoints. Return `429` + `Retry-After`.
|
|
84
|
+
- Set request body size limits, timeouts and pagination caps. Guard against ReDoS (avoid catastrophic regexes) and GraphQL query depth/complexity abuse.
|
|
85
|
+
- Add CAPTCHA/bot protection to signup and contact forms where abuse is likely.
|
|
86
|
+
|
|
87
|
+
## 10. Dependencies and Supply Chain
|
|
88
|
+
|
|
89
|
+
- Keep lockfiles committed. Automate updates and vulnerability scans (Dependabot, Renovate, `npm audit`, `pip-audit`, Trivy).
|
|
90
|
+
- Review new dependencies (maintenance, popularity, install scripts). Prefer fewer dependencies.
|
|
91
|
+
- Pin container base images, build from trusted sources, sign artifacts where possible. Run containers as non-root with minimal capabilities.
|
|
92
|
+
- Use Subresource Integrity (SRI) for third-party scripts and CDNs.
|
|
93
|
+
|
|
94
|
+
## 11. Logging, Monitoring and Incident Response
|
|
95
|
+
|
|
96
|
+
- Log security events (logins, failures, permission denials, password/role changes, admin actions) with who/what/when/where. Protect log integrity and access.
|
|
97
|
+
- Alert on anomalies (spikes in 401/403/429, unusual geographies, mass downloads).
|
|
98
|
+
- Have an incident response plan: contacts, revocation of keys/sessions, communication, and post-mortems.
|
|
99
|
+
|
|
100
|
+
## 12. Secure Development Process
|
|
101
|
+
|
|
102
|
+
- Threat-model new features (STRIDE: spoofing, tampering, repudiation, info disclosure, DoS, elevation).
|
|
103
|
+
- Add SAST, dependency and secret scanning to CI, and DAST/pen-testing for production systems.
|
|
104
|
+
- Code review includes a security pass. Use the checklist below.
|
|
105
|
+
- Fail securely: on error, deny access rather than allow.
|
|
106
|
+
|
|
107
|
+
## Review Checklist
|
|
108
|
+
|
|
109
|
+
- [ ] Auth via vetted library/provider; passwords hashed with Argon2id/bcrypt; MFA available
|
|
110
|
+
- [ ] Cookies `HttpOnly; Secure; SameSite`; JWT claims validated; CSRF handled
|
|
111
|
+
- [ ] Server-side authorization on every resource; IDOR and mass assignment prevented
|
|
112
|
+
- [ ] Parameterized queries; output encoding; SSRF/path-traversal/open-redirect guards
|
|
113
|
+
- [ ] Upload validation and safe storage
|
|
114
|
+
- [ ] No secrets in code/logs/client; TLS + HSTS; sensitive data encrypted
|
|
115
|
+
- [ ] Security headers and CSP set; strict CORS allowlist
|
|
116
|
+
- [ ] Rate limiting, size limits, timeouts
|
|
117
|
+
- [ ] Dependencies scanned and pinned; security events logged and monitored
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: changelog-and-versioning
|
|
3
|
+
description: Rules for maintaining CHANGELOG.md (Keep a Changelog format) and Semantic Versioning. Use when making any user-facing change, fixing a bug, deprecating or removing a feature, preparing a release, or deciding a version number.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Changelog and Versioning
|
|
7
|
+
|
|
8
|
+
The changelog tells **users and operators** what changed between versions. It is not a copy of the git log. Git records every commit, the changelog records what matters to someone upgrading.
|
|
9
|
+
|
|
10
|
+
## Modes: automated and manual
|
|
11
|
+
|
|
12
|
+
Check which mode applies before touching `CHANGELOG.md`: **automated mode applies only if `release-please-config.json` exists at the repository root.** Otherwise use manual mode.
|
|
13
|
+
|
|
14
|
+
**Automated mode (release-please).** `release-please-config.json` and the release-please workflow generate `CHANGELOG.md` and the version bump from Conventional Commits.
|
|
15
|
+
- The squash-merged PR title (a Conventional Commit) **is** the changelog entry. Write it for the reader: the user-visible effect, not the implementation.
|
|
16
|
+
- Do **not** hand-edit `CHANGELOG.md` or version fields. release-please keeps a "release PR" open. Merging it updates the changelog, bumps the version and tags `vX.Y.Z`. Fix wording by editing the release PR before merging.
|
|
17
|
+
- Sections follow Keep a Changelog names: `feat` becomes Added, `fix` becomes Fixed, `perf` and `revert` become Changed. `docs`, `refactor`, `test`, `build`, `ci`, `chore` and `style` are hidden. Breaking changes (`!` or a `BREAKING CHANGE:` footer) get their own call-out and a major bump. For security fixes use `fix(security): ...` and say so plainly. For deprecations and removals use clear wording, and `!` when breaking.
|
|
18
|
+
|
|
19
|
+
**Manual mode.** If there is no `release-please-config.json` at the repository root, follow sections 1-5 below and keep an `[Unreleased]` section. Never mix the two modes. Section 6 (SemVer) applies to both.
|
|
20
|
+
|
|
21
|
+
## 1. Format (Keep a Changelog 1.1.0)
|
|
22
|
+
|
|
23
|
+
`CHANGELOG.md` at the repository root, newest release first, with an `Unreleased` section at the top:
|
|
24
|
+
|
|
25
|
+
```markdown
|
|
26
|
+
# Changelog
|
|
27
|
+
|
|
28
|
+
All notable changes to this project are documented in this file.
|
|
29
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
30
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
31
|
+
|
|
32
|
+
## [Unreleased]
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
- Passkey login for web accounts. (#482)
|
|
36
|
+
|
|
37
|
+
## [1.4.0] - 2026-11-11
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
- ...
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
- ...
|
|
44
|
+
|
|
45
|
+
### Deprecated
|
|
46
|
+
- ...
|
|
47
|
+
|
|
48
|
+
### Removed
|
|
49
|
+
- ...
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
- ...
|
|
53
|
+
|
|
54
|
+
### Security
|
|
55
|
+
- ...
|
|
56
|
+
|
|
57
|
+
[Unreleased]: https://github.com/org/repo/compare/v1.4.0...HEAD
|
|
58
|
+
[1.4.0]: https://github.com/org/repo/compare/v1.3.0...v1.4.0
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Sections (use only those that apply, in this order)**
|
|
62
|
+
|
|
63
|
+
| Section | Content |
|
|
64
|
+
|---|---|
|
|
65
|
+
| Added | New features |
|
|
66
|
+
| Changed | Changes to existing behavior |
|
|
67
|
+
| Deprecated | Features that will be removed soon |
|
|
68
|
+
| Removed | Features removed in this release |
|
|
69
|
+
| Fixed | Bug fixes |
|
|
70
|
+
| Security | Vulnerability fixes (reference CVE/advisory when public) |
|
|
71
|
+
|
|
72
|
+
## 2. What to Log (and What Not To)
|
|
73
|
+
|
|
74
|
+
**Log** anything a user, API consumer, operator or integrator would notice or must act on:
|
|
75
|
+
- New or changed features, UI behavior, API endpoints/fields, CLI flags, config options, environment variables
|
|
76
|
+
- Bug fixes visible to users
|
|
77
|
+
- Performance changes that are noticeable
|
|
78
|
+
- Deprecations and removals, with migration guidance
|
|
79
|
+
- Security fixes
|
|
80
|
+
- Required actions for upgrading (migrations, config changes)
|
|
81
|
+
- Dependency changes only when they affect users (new minimum runtime version, license change)
|
|
82
|
+
|
|
83
|
+
**Don't log**
|
|
84
|
+
- Internal refactors, formatting, test-only changes, CI tweaks, comment/docs typos
|
|
85
|
+
- Individual commits, work-in-progress details, or developer chatter
|
|
86
|
+
|
|
87
|
+
## 3. Writing Entries
|
|
88
|
+
|
|
89
|
+
- Write for the **reader**, in plain language, describing the effect and not the implementation.
|
|
90
|
+
- Good: "Fixed duplicate charges when the payment button was clicked twice."
|
|
91
|
+
- Bad: "Refactored PaymentService.create to use idempotency middleware."
|
|
92
|
+
- Start with a past-tense or neutral verb (Added, Fixed, Removed) or a clear noun phrase. Be consistent.
|
|
93
|
+
- One line per change, with a reference (issue/PR number) where possible.
|
|
94
|
+
- **Breaking changes** are called out clearly with migration steps, ideally prefixed `**BREAKING:**`.
|
|
95
|
+
- Don't use vague entries ("Various fixes", "Improvements", "Bug fixes").
|
|
96
|
+
- Use ISO dates (`YYYY-MM-DD`). Never use relative dates.
|
|
97
|
+
|
|
98
|
+
## 4. When to Update (Workflow)
|
|
99
|
+
|
|
100
|
+
- **With the change, in the same PR/commit.** Add the entry under `## [Unreleased]` in the appropriate section. A PR that changes user-facing behavior without a changelog entry is incomplete.
|
|
101
|
+
- Pure internal changes (`refactor`, `test`, `ci`, `style`, `chore`, internal `docs`) usually need no entry.
|
|
102
|
+
- Mapping from Conventional Commits:
|
|
103
|
+
|
|
104
|
+
| Commit | Changelog |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `feat` | Added (or Changed) |
|
|
107
|
+
| `fix` | Fixed (or Security) |
|
|
108
|
+
| `perf` | Changed |
|
|
109
|
+
| `feat!` / `BREAKING CHANGE` | Changed/Removed + **BREAKING** note |
|
|
110
|
+
| `revert` | Fixed/Changed, as appropriate |
|
|
111
|
+
| `docs`, `refactor`, `test`, `ci`, `chore`, `style` | usually none |
|
|
112
|
+
|
|
113
|
+
## 5. Release Process
|
|
114
|
+
|
|
115
|
+
1. Decide the version number from the changes (section 6).
|
|
116
|
+
2. In `CHANGELOG.md`: rename `[Unreleased]` content into `## [X.Y.Z] - YYYY-MM-DD`, then add a fresh empty `## [Unreleased]` above it. Update the comparison links at the bottom.
|
|
117
|
+
3. Update the version in the manifest files (`package.json`, `pyproject.toml`, etc.).
|
|
118
|
+
4. Commit: `chore(release): vX.Y.Z`.
|
|
119
|
+
5. Create an annotated tag `vX.Y.Z` and push. CI builds and publishes from the tag.
|
|
120
|
+
6. Publish release notes (GitHub Release) using the changelog section for that version.
|
|
121
|
+
|
|
122
|
+
Automation is welcome (release-please, semantic-release, changesets). If used, keep a human edit pass so entries read well for users, and don't mix automated and manual formats.
|
|
123
|
+
|
|
124
|
+
## 6. Semantic Versioning (MAJOR.MINOR.PATCH)
|
|
125
|
+
|
|
126
|
+
| Bump | When | Example |
|
|
127
|
+
|---|---|---|
|
|
128
|
+
| **MAJOR** | Backward-incompatible changes to the public API/contract | 1.4.2 → 2.0.0 |
|
|
129
|
+
| **MINOR** | Backward-compatible new functionality; deprecations | 1.4.2 → 1.5.0 |
|
|
130
|
+
| **PATCH** | Backward-compatible bug fixes | 1.4.2 → 1.4.3 |
|
|
131
|
+
|
|
132
|
+
- Define what the "public API" is for this project (HTTP API, library exports, CLI, config schema, DB schema if consumed externally).
|
|
133
|
+
- `0.y.z` is initial development: anything may change. Move to `1.0.0` when the API is considered stable or in production use.
|
|
134
|
+
- Pre-releases: `1.5.0-rc.1`, `1.5.0-beta.2`. Build metadata: `1.5.0+build.7`.
|
|
135
|
+
- Never change or re-publish an already-released version. Fix forward with a new version.
|
|
136
|
+
- Deprecate first (MINOR), then remove in the next MAJOR, with at least one release of notice and a migration path.
|
|
137
|
+
- Web applications without external API consumers may use date-based or build-number versions, but still keep a changelog.
|
|
138
|
+
|
|
139
|
+
## 7. Examples
|
|
140
|
+
|
|
141
|
+
```markdown
|
|
142
|
+
## [Unreleased]
|
|
143
|
+
|
|
144
|
+
### Added
|
|
145
|
+
- Export orders to CSV from the Orders page. (#511)
|
|
146
|
+
|
|
147
|
+
### Fixed
|
|
148
|
+
- Cart total no longer shows NaN when a coupon expires during checkout. (#517)
|
|
149
|
+
|
|
150
|
+
### Security
|
|
151
|
+
- Fixed an access control flaw that allowed viewing other customers' invoices by changing the URL ID. (GHSA-xxxx-xxxx-xxxx)
|
|
152
|
+
|
|
153
|
+
## [2.0.0] - 2026-11-11
|
|
154
|
+
|
|
155
|
+
### Changed
|
|
156
|
+
- **BREAKING:** `GET /v1/orders` now returns cursor-based pagination (`nextCursor`) instead of `page`/`pageSize`. See the migration guide in docs/migrations/2.0.md.
|
|
157
|
+
|
|
158
|
+
### Removed
|
|
159
|
+
- **BREAKING:** Dropped Node 18 support; Node 20+ is required.
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Review Checklist
|
|
163
|
+
|
|
164
|
+
- [ ] Manual mode: user-facing change has an entry under `[Unreleased]` in the correct section. Automated mode: the PR title reads as the release note
|
|
165
|
+
- [ ] Entry describes the user-visible effect, is specific, and references the issue/PR
|
|
166
|
+
- [ ] Breaking changes and deprecations flagged with migration steps
|
|
167
|
+
- [ ] Version bump matches the change types (SemVer)
|
|
168
|
+
- [ ] On release: date set, new empty `Unreleased` added, links updated, tag created
|
|
169
|
+
- [ ] No internal-only noise, no secrets or sensitive vulnerability details before a fix is public
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: database-best-practices
|
|
3
|
+
description: Rules for database design, queries, migrations and data access (primarily relational/SQL). Use when designing schemas, writing queries or ORM code, adding indexes, writing migrations, handling transactions, or diagnosing slow queries and N+1 problems.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Database Best Practices
|
|
7
|
+
|
|
8
|
+
Examples use SQL (PostgreSQL-flavored). Principles apply to MySQL and most relational databases, and many apply to NoSQL.
|
|
9
|
+
|
|
10
|
+
## 1. Schema Design
|
|
11
|
+
|
|
12
|
+
- Model the domain first. Normalize to at least 3NF by default, and denormalize deliberately only for measured read performance.
|
|
13
|
+
- Every table has a primary key. Choose stable surrogate keys (`bigint` identity or UUIDv7/ULID for distributed/public IDs). Don't use mutable business data (emails) as primary keys.
|
|
14
|
+
- Use the correct types:
|
|
15
|
+
- Money: `numeric(p,s)` or integer minor units, never `float`.
|
|
16
|
+
- Time: `timestamptz` stored in UTC. Convert at the edges.
|
|
17
|
+
- Booleans as `boolean`. Enums via `enum`/lookup table/`CHECK` constraint. JSON columns (`jsonb`) only for genuinely flexible data, not as a way to skip modeling.
|
|
18
|
+
- Enforce integrity in the database, not only in app code:
|
|
19
|
+
- `NOT NULL` by default, `UNIQUE`, `CHECK`, and **foreign keys** with deliberate `ON DELETE` behavior.
|
|
20
|
+
- Naming: consistent, lowercase `snake_case`, singular or plural table names (pick one), `<table>_id` for foreign keys, `created_at` / `updated_at` on tables.
|
|
21
|
+
- Soft delete (`deleted_at`) only when needed (audit/recovery), and remember to filter it consistently (partial indexes and unique constraints must account for it).
|
|
22
|
+
- Many-to-many via a join table with a composite unique key.
|
|
23
|
+
|
|
24
|
+
## 2. Indexing
|
|
25
|
+
|
|
26
|
+
- Index primary keys (automatic), foreign keys, and columns used in `WHERE`, `JOIN`, `ORDER BY` of frequent queries.
|
|
27
|
+
- Composite indexes: put equality columns first, then range/sort columns. Order matters. An index on `(a, b)` serves queries on `a` and `a,b`, not `b` alone.
|
|
28
|
+
- Use partial indexes and covering indexes (`INCLUDE`) for hot paths.
|
|
29
|
+
- Don't over-index. Each index slows writes and uses storage. Remove unused indexes (check usage statistics).
|
|
30
|
+
- Verify with `EXPLAIN (ANALYZE, BUFFERS)`. Look for sequential scans on large tables, row estimate mismatches and sorts spilling to disk.
|
|
31
|
+
- Avoid patterns that defeat indexes: functions on indexed columns (`WHERE lower(email) = ...` without a functional index), leading wildcards (`LIKE '%abc'`), implicit type casts.
|
|
32
|
+
- For text search use full-text search (`tsvector`/GIN, or a search engine) rather than `LIKE '%term%'`.
|
|
33
|
+
|
|
34
|
+
## 3. Queries and Data Access
|
|
35
|
+
|
|
36
|
+
- **Never** build SQL from strings with user input. Use parameters (see `backend-security`).
|
|
37
|
+
- Select only the needed columns. Avoid `SELECT *` in application code.
|
|
38
|
+
- Avoid **N+1 queries**: load related data with joins, `IN (...)` batching, or ORM eager loading (`include`/`joinedload`/`prefetch_related`). Watch query counts per request in development and tests.
|
|
39
|
+
- Paginate everything that can grow. Prefer keyset (seek) pagination (`WHERE (created_at, id) < (?, ?) ORDER BY created_at DESC, id DESC LIMIT 50`) over large `OFFSET`.
|
|
40
|
+
- Push filtering, aggregation and sorting into the database instead of in application memory.
|
|
41
|
+
- Use bulk operations for batch writes (`INSERT ... VALUES (...),(...)`, `COPY`, bulk APIs), in chunks.
|
|
42
|
+
- Use `EXISTS` rather than `COUNT(*) > 0` for existence checks.
|
|
43
|
+
- Set statement timeouts and lock timeouts to protect the database from runaway queries.
|
|
44
|
+
- Use read replicas for heavy reads only when replication lag is acceptable, and route deliberately.
|
|
45
|
+
|
|
46
|
+
## 4. ORM Usage
|
|
47
|
+
|
|
48
|
+
- ORMs are fine for CRUD. Drop to hand-written SQL for complex reporting or performance-critical queries.
|
|
49
|
+
- Keep ORM entities inside the data-access layer (repositories). Return domain objects/DTOs to services (DIP).
|
|
50
|
+
- Understand the SQL your ORM generates. Log slow queries and inspect them.
|
|
51
|
+
- Don't rely on lazy loading in request handlers, which causes hidden N+1.
|
|
52
|
+
|
|
53
|
+
## 5. Transactions and Concurrency
|
|
54
|
+
|
|
55
|
+
- Wrap multi-step writes that must be atomic in one transaction. Keep transactions short and don't do network calls or user interaction inside them.
|
|
56
|
+
- Know your isolation level (PostgreSQL default is Read Committed). Use `SERIALIZABLE` or explicit locks for tricky invariants.
|
|
57
|
+
- Prevent lost updates: optimistic locking (`version` column: `UPDATE ... WHERE id = ? AND version = ?`) or `SELECT ... FOR UPDATE`.
|
|
58
|
+
- Use unique constraints plus upserts (`INSERT ... ON CONFLICT`) to make operations idempotent and race-safe, instead of check-then-insert.
|
|
59
|
+
- Acquire locks in a consistent order to avoid deadlocks. Retry on serialization failures/deadlocks.
|
|
60
|
+
- Use `SELECT ... FOR UPDATE SKIP LOCKED` for job-queue style workloads.
|
|
61
|
+
|
|
62
|
+
## 6. Migrations
|
|
63
|
+
|
|
64
|
+
- All schema changes are versioned migration files in source control (Flyway, Liquibase, Prisma Migrate, Alembic, Knex, EF Migrations). Never alter production schema by hand.
|
|
65
|
+
- Migrations are repeatable in CI against a fresh database and applied automatically in the pipeline.
|
|
66
|
+
- Make them **backward compatible** using the expand → migrate → contract pattern so old and new app versions can run at the same time:
|
|
67
|
+
1. Expand: add new nullable column/table/index.
|
|
68
|
+
2. Deploy the app writing to both / reading the new one. Backfill data in batches.
|
|
69
|
+
3. Contract: remove old columns after all code stops using them.
|
|
70
|
+
- Avoid long locks on big tables: add indexes `CONCURRENTLY` (PostgreSQL), add columns without volatile defaults where the engine requires a rewrite, backfill in batches, and add `NOT NULL`/FK constraints in a safe two-step way (`NOT VALID` then `VALIDATE`).
|
|
71
|
+
- Never edit an already-applied migration. Add a new one. Have a rollback/forward-fix plan.
|
|
72
|
+
- Keep schema migrations and large data migrations separate.
|
|
73
|
+
|
|
74
|
+
## 7. Backups, Recovery and Operations
|
|
75
|
+
|
|
76
|
+
- Automated backups with point-in-time recovery. **Test restores regularly**. A backup that has never been restored is not a backup.
|
|
77
|
+
- Define RPO/RTO. Monitor replication, disk, connections, locks, slow queries, bloat/vacuum health.
|
|
78
|
+
- Use connection pooling (PgBouncer or the app pool), sized deliberately (not one connection per request). Know the max connections limit.
|
|
79
|
+
- Use least-privilege DB users: the app can't `DROP`, and migrations use a separate privileged role. Separate read-only users for analytics.
|
|
80
|
+
- Keep dev/staging data anonymized. Never copy raw production personal data into lower environments.
|
|
81
|
+
|
|
82
|
+
## 8. Choosing a Data Store
|
|
83
|
+
|
|
84
|
+
- Default to a relational database (PostgreSQL is a strong general-purpose choice). Add other stores for specific needs, not by habit:
|
|
85
|
+
- Redis: caching, rate limits, ephemeral state, queues.
|
|
86
|
+
- Document stores: truly schema-flexible aggregates.
|
|
87
|
+
- Search engines (Elasticsearch/OpenSearch/Meilisearch): full-text relevance, faceting.
|
|
88
|
+
- Object storage (S3-compatible): files and large blobs. Store only the key/metadata in the DB.
|
|
89
|
+
- Analytical stores (warehouse/columnar): reporting and heavy aggregation, separated from the OLTP database.
|
|
90
|
+
- Each additional datastore adds operational cost. Justify it (YAGNI).
|
|
91
|
+
|
|
92
|
+
## 9. Data Privacy and Lifecycle
|
|
93
|
+
|
|
94
|
+
- Classify personal and sensitive data. Encrypt where required. Limit who and what can read it.
|
|
95
|
+
- Define retention and deletion procedures (including backups and derived data). Keep audit trails for sensitive changes.
|
|
96
|
+
|
|
97
|
+
## Review Checklist
|
|
98
|
+
|
|
99
|
+
- [ ] Primary keys, correct types, NOT NULL, FKs, unique/check constraints
|
|
100
|
+
- [ ] Indexes match query patterns; verified with EXPLAIN; no unused/duplicate indexes
|
|
101
|
+
- [ ] Parameterized queries; no `SELECT *`; no N+1; pagination everywhere
|
|
102
|
+
- [ ] Transactions short and correct; race conditions handled by constraints/locks/versions
|
|
103
|
+
- [ ] Migrations versioned, backward compatible, safe on large tables
|
|
104
|
+
- [ ] Backups tested; connection pooling; least-privilege DB users; timeouts set
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: git-commit-and-workflow
|
|
3
|
+
description: Git commit, branch and pull request best practices using Conventional Commits. Use whenever creating commits, naming branches, preparing pull requests, writing commit messages, or when asked to commit, push, merge or release code.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Git Commit and Workflow Rules
|
|
7
|
+
|
|
8
|
+
A good history lets people (and agents) understand *what changed and why* without reading every diff, and lets tools generate changelogs and versions automatically.
|
|
9
|
+
|
|
10
|
+
## 1. Commit Message Format (Conventional Commits 1.0)
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
<type>(<optional scope>): <subject>
|
|
14
|
+
|
|
15
|
+
<optional body: what and why, wrapped at ~72 chars>
|
|
16
|
+
|
|
17
|
+
<optional footers: BREAKING CHANGE, Refs, Co-authored-by>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Types**
|
|
21
|
+
|
|
22
|
+
| Type | Use for | Version bump |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| `feat` | New user-facing capability | minor |
|
|
25
|
+
| `fix` | Bug fix | patch |
|
|
26
|
+
| `perf` | Performance improvement | patch |
|
|
27
|
+
| `refactor` | Code change with no behavior change | none |
|
|
28
|
+
| `docs` | Documentation only | none |
|
|
29
|
+
| `test` | Adding/fixing tests | none |
|
|
30
|
+
| `build` | Build system, dependencies | none |
|
|
31
|
+
| `ci` | CI configuration | none |
|
|
32
|
+
| `style` | Formatting only (no logic) | none |
|
|
33
|
+
| `chore` | Maintenance not fitting above | none |
|
|
34
|
+
| `revert` | Reverting a commit | depends |
|
|
35
|
+
|
|
36
|
+
**Subject rules**
|
|
37
|
+
- Imperative mood: "add", "fix", "remove" (not "added", "fixes").
|
|
38
|
+
- Lowercase after the colon, no trailing period, 72 characters or fewer.
|
|
39
|
+
- Describe the change's effect, not the activity ("fix crash on empty cart", not "fix bug" or "update stuff").
|
|
40
|
+
- Scope is the module/area: `feat(auth): add passkey login`.
|
|
41
|
+
|
|
42
|
+
**Body**
|
|
43
|
+
- Explain **why** the change was needed and any trade-offs or alternatives. The diff already shows *what*.
|
|
44
|
+
- Wrap at about 72 characters. Separate from the subject with a blank line.
|
|
45
|
+
|
|
46
|
+
**Footers**
|
|
47
|
+
- Breaking change: `BREAKING CHANGE: <what broke and how to migrate>` or `!` after type/scope (`feat(api)!: remove v1 endpoints`). Triggers a major version bump.
|
|
48
|
+
- Issue links: `Refs: #123`, `Closes: #123`.
|
|
49
|
+
|
|
50
|
+
**Examples**
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
feat(checkout): add idempotency key to payment creation
|
|
54
|
+
|
|
55
|
+
Duplicate submissions on flaky networks created double charges.
|
|
56
|
+
The key is stored for 24h and replays the original response.
|
|
57
|
+
|
|
58
|
+
Closes: #482
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
fix(auth): reject JWTs with alg=none
|
|
63
|
+
|
|
64
|
+
BREAKING CHANGE: tokens signed without a signature are no longer accepted.
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 2. Commit Hygiene
|
|
68
|
+
|
|
69
|
+
- **Atomic commits:** one logical change per commit. A commit should build and pass tests on its own.
|
|
70
|
+
- Keep tests and docs for a change in the same commit as the change.
|
|
71
|
+
- Separate refactors/formatting from behavior changes (never hide a logic change inside a reformat commit).
|
|
72
|
+
- Don't commit: secrets, `.env` files, credentials, build output, `node_modules`, large binaries, editor/OS files. Maintain `.gitignore`.
|
|
73
|
+
- No `WIP`, `fix stuff`, `asdf` commits on shared branches. Squash or rewrite local-only commits before pushing.
|
|
74
|
+
- Review `git status` and `git diff --staged` before every commit. Stage intentionally (`git add -p` or specific paths), not blindly `git add -A`.
|
|
75
|
+
- Run lint, type check and relevant tests before committing. Use pre-commit hooks (husky, lefthook, pre-commit) and `commitlint` to enforce format.
|
|
76
|
+
|
|
77
|
+
## 3. Branching
|
|
78
|
+
|
|
79
|
+
- Default to **trunk-based development**: short-lived branches (ideally under 2 days), merged often into `main`. Use feature flags for unfinished work.
|
|
80
|
+
- Branch names: `<type>/<short-kebab-description>` with an optional issue ID: `feat/passkey-login`, `fix/482-double-charge`, `chore/bump-eslint`.
|
|
81
|
+
- `main` is always deployable and protected: required reviews, passing CI, no direct pushes, no force pushes.
|
|
82
|
+
- Keep branches updated by rebasing on `main` (for private branches) or merging, per team convention. Be consistent.
|
|
83
|
+
|
|
84
|
+
## 4. Pull Requests
|
|
85
|
+
|
|
86
|
+
- Small and focused: ideally under about 400 changed lines, one concern each. Split large work into stacked or sequential PRs.
|
|
87
|
+
- Title follows Conventional Commits (squash-merge uses it as the commit message).
|
|
88
|
+
- Description includes: **what and why**, how it was tested, screenshots for UI, migration/rollback notes, linked issue, breaking changes.
|
|
89
|
+
- Self-review the diff before requesting review. Remove debug code and commented-out code.
|
|
90
|
+
- CI must pass. Address review comments with follow-up commits, then squash on merge (or keep a clean history if rebase-merging).
|
|
91
|
+
- Prefer **squash merge** for feature branches (one clean commit per PR) unless the individual commits are well crafted and meaningful.
|
|
92
|
+
|
|
93
|
+
PR template:
|
|
94
|
+
|
|
95
|
+
```markdown
|
|
96
|
+
## Summary
|
|
97
|
+
<!-- What changed and why -->
|
|
98
|
+
|
|
99
|
+
## Changes
|
|
100
|
+
-
|
|
101
|
+
|
|
102
|
+
## Testing
|
|
103
|
+
<!-- How you verified it: tests added, manual steps -->
|
|
104
|
+
|
|
105
|
+
## Risks / Rollback
|
|
106
|
+
<!-- Migrations, flags, breaking changes, how to revert -->
|
|
107
|
+
|
|
108
|
+
## Checklist
|
|
109
|
+
- [ ] Tests added/updated and passing
|
|
110
|
+
- [ ] Docs / OpenAPI updated
|
|
111
|
+
- [ ] PR title is a Conventional Commit written for the changelog reader (if release-please is configured, it becomes the release note)
|
|
112
|
+
- [ ] MEMORY.md updated (if new lasting knowledge)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## 5. Safety Rules (Especially for AI Agents)
|
|
116
|
+
|
|
117
|
+
- **Commit only when the user or project workflow asks for it.** Don't push, merge or open PRs unprompted.
|
|
118
|
+
- Never `git push --force` to shared branches (`main`, release branches). If a force push is needed on your own branch, use `--force-with-lease`.
|
|
119
|
+
- Never rewrite (amend, rebase, reset) commits that have already been pushed and shared.
|
|
120
|
+
- Never bypass hooks or checks (`--no-verify`, `--no-gpg-sign`) to make a commit pass. Fix the underlying failure.
|
|
121
|
+
- Never use destructive commands (`git reset --hard`, `git clean -fd`, `git checkout .`, branch deletion) without explicit confirmation, because they can destroy uncommitted work.
|
|
122
|
+
- If secrets were committed, treat them as compromised: rotate them first, then clean history.
|
|
123
|
+
- Don't commit unrelated changes you didn't make or don't understand. Leave them and mention them.
|
|
124
|
+
- If a pre-commit hook modifies files, review the changes and include them in a new commit rather than amending something already pushed.
|
|
125
|
+
|
|
126
|
+
## 6. Releases and Tags
|
|
127
|
+
|
|
128
|
+
- Version with Semantic Versioning (`MAJOR.MINOR.PATCH`). See `changelog-and-versioning`.
|
|
129
|
+
- Tag releases `vX.Y.Z` (annotated: `git tag -a v1.4.0 -m "v1.4.0"`). Releases are built from tags in CI.
|
|
130
|
+
- If release-please is configured (a `release-please-config.json` at the repository root), the PR title becomes the release note: merging the release PR updates `CHANGELOG.md`, bumps the version and tags `vX.Y.Z`. Use squash merges so the PR title becomes the commit message. Otherwise update `CHANGELOG.md` by hand. See `changelog-and-versioning` for both modes.
|
|
131
|
+
- Hotfixes: branch from the release tag, fix, tag a patch release, and merge the fix back to `main`.
|
|
132
|
+
|
|
133
|
+
## Review Checklist
|
|
134
|
+
|
|
135
|
+
- [ ] Message follows `type(scope): subject`, imperative, ≤72 chars, explains why in the body
|
|
136
|
+
- [ ] One logical change; tests and docs included; builds and passes locally
|
|
137
|
+
- [ ] No secrets, generated files or unrelated changes staged
|
|
138
|
+
- [ ] Branch name and PR title follow convention; PR is small and described
|
|
139
|
+
- [ ] No force pushes, no skipped hooks, no history rewrites of shared commits
|
|
140
|
+
- [ ] Commit/PR title written as a release note; changelog updated per `changelog-and-versioning`; MEMORY.md updated when required
|