Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/add-fastify-hooks-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thecodepace/fastify-skills": minor
---

Add comprehensive Fastify hooks rule covering all 15 hooks from the official documentation: request/reply hooks (`onRequest`, `preParsing`, `preValidation`, `preHandler`, `preSerialization`, `onError`, `onSend`, `onResponse`, `onTimeout`, `onRequestAbort`) and application hooks (`onReady`, `onListen`, `onClose`, `onRoute`, `onRegister`), with annotated lifecycle diagram, correct/incorrect examples, hook scoping guidance, route-level hooks, and async vs callback style.
19 changes: 19 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Copilot Instructions

## Documentation Sync Requirement

When adding, updating, or deleting a skill or any of its rules, **always keep the following files in sync** before considering the task done:

- **`README.md`** — Update the rules table or skill listing to reflect the change.
- **`AGENTS.md`** — Update the rules table and any related guidance for the affected skill.
- **`skills/{skill-name}/SKILL.md`** — Update the skill's own definition, usage entries, and rules table as needed.

These updates are mandatory whenever:

- A new skill is created
- A new rule is added to an existing skill
- An existing rule is renamed, moved, or removed
- A skill is deleted

Do not consider the task complete until all three files accurately reflect the current state of the skill.

---

## Changeset Requirement

When completing work for a PR, **always ensure a changeset file exists** before considering the task done.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Apply Fastify best practices when creating servers, plugins, routes, schemas, ho
| Schema Validation (Zod) | HIGH | Type-safe validation with Zod + `fastify-type-provider-zod` |
| Encapsulation | HIGH | Proper scope isolation and when to use `fastify-plugin` |
| Error Handling | HIGH | Custom error handlers, `@fastify/error`, `@fastify/sensible`, 404 handling |
| Hooks & Lifecycle | MEDIUM | Request lifecycle hooks for auth, logging, rate limiting |
| Hooks & Lifecycle | MEDIUM | Full lifecycle hook coverage: request pipeline (`onRequest` → `onResponse`), application hooks (`onReady`, `onClose`), scoped hooks, and async/callback patterns |
| Testing | HIGH | Test with `inject()`, buildServer pattern, vitest/node:test |
| TypeScript | MEDIUM | Type providers, module augmentation, typed decorators |
| Decorators | MEDIUM | Extend the Fastify instance, request, and reply with `decorate` / `decorateRequest` / `decorateReply` |
Expand Down
2 changes: 1 addition & 1 deletion skills/fastify-best-practise/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The rules are organized by topic in the `rules/` directory. Each rule follows a
| Schema Validation (Zod) | [schema-validation-zod.md](rules/schema-validation-zod.md) | HIGH | Type-safe validation with Zod + `fastify-type-provider-zod` |
| Encapsulation | [encapsulation.md](rules/encapsulation.md) | HIGH | Proper scope isolation and when to use `fastify-plugin` |
| Error Handling | [error-handling.md](rules/error-handling.md) | HIGH | Custom error handlers, `@fastify/error`, 404 handling, structured responses |
| Hooks & Lifecycle | [hooks-lifecycle.md](rules/hooks-lifecycle.md) | MEDIUM | Request lifecycle hooks for auth, logging, rate limiting |
| Hooks & Lifecycle | [hooks-lifecycle.md](rules/hooks-lifecycle.md) | MEDIUM | All request/reply and application hooks: onRequest, preParsing, preValidation, preHandler, preSerialization, onError, onSend, onResponse, onTimeout, onRequestAbort, onReady, onListen, onClose, onRoute, onRegister |
| Testing | [testing.md](rules/testing.md) | HIGH | Test with `inject()`, buildServer pattern, vitest/node:test |
| TypeScript | [typescript-integration.md](rules/typescript-integration.md) | MEDIUM | Type providers, module augmentation, typed decorators |
| Decorators | [decorators.md](rules/decorators.md) | MEDIUM | Extend the Fastify instance, request, and reply with `decorate` / `decorateRequest` / `decorateReply` |
Expand Down
Loading