Agent skill
hapi
Use when building @hapi/hapi servers, routes, plugins, auth schemes, HTTP APIs, request lifecycle, caching, stale-while-revalidate, server methods, views, startup sequences, or response marshalling.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/hapi
SKILL.md
Hapi
Quick Start
const server = Hapi.server({ port: 3000 });
server.route({ method: 'GET', path: '/', handler: () => 'ok' });
await server.start();
Critical Rules
- Compose with decorations & methods - Expose services via decorations and reusable logic via methods
- Follow the lifecycle - 24-step request flow; see lifecycle overview
- Auth is three layers - scheme → strategy → default; see server auth
- Validate at the route - Use joi schemas on params, query, payload, headers; see validation
- Type routes with Refs - Use
ServerRoute<Refs>pattern; see route scaffold
Workflow
- Create server - server overview for constructor options
- Register plugins - plugins and plugin structure
- Configure auth - auth schemes and route auth
- Define routes - route overview with handlers
- Add extensions - lifecycle hooks and pre-handlers
Key Patterns
| Topic | Reference |
|---|---|
| Request/response objects | request, response |
| Response toolkit (h) | toolkit |
| Sessions (yar) | sessions |
| Caching & CORS | cache-cors, server cache, catbox-memory engine, catbox-fs engine, catbox-redis engine |
| Security headers | security |
| Payload parsing | payload |
| Decorations & methods | decorations, methods |
| MIME types (mimos) | mimos |
| Realms & plugin scoping | realm |
| Response marshalling | marshal pipeline |
| File serving (inert) | overview, file handler, directory handler |
| Basic authentication | basic auth |
| Error handling (Boom) | boom errors |
| Error filtering (Bounce) | bounce utility |
| WebSockets (nes) | overview, subscriptions, client |
| Startup & shutdown | startup lifecycle |
| Events | events |
| Testing (server.inject) | network |
| TypeScript overview | typescript |
| TypeScript auth typing | auth-scheme, type-author |
| JWT authentication | jwt overview, validate function, token API |
| TypeScript plugins | plugin-scaffold |
| Views & templates | vision overview, engines, context & layouts |
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?