pb-extend
Extend PocketBase with custom hooks and routes in JS or Go. Use when user wants to add custom API routes, modify PocketBase behavior, or add server-side logic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Extend PocketBase with custom hooks and routes in JS or Go. Use when user wants to add custom API routes, modify PocketBase behavior, or add server-side logic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Control a real browser over Chrome DevTools Protocol (CDP). Use when user asks to open a page, click an element, take a screenshot, or any browser automation. Requires Chrome remote debugging enabled.
Operate PocketBase via its REST API. Use for CRUD operations on collections, authentication, querying records with filters, and managing PocketBase data.
Execute git commit with conventional commit message analysis, intelligent staging, and message generation. Use when user asks to commit changes, create a git commit, or mentions "/commit". Supports: (1) Auto-detecting type and scope from changes, (2) Generating conventional commit messages from diff, (3) Interactive commit with optional type/scope/description overrides, (4) Intelligent file staging for logical grouping
| name | pb-extend |
| description | Extend PocketBase with custom hooks and routes in JS or Go. Use when user wants to add custom API routes, modify PocketBase behavior, or add server-side logic. |
| license | MIT |
| allowed-tools | Bash |
Reference: https://pocketbase.io/docs/js-overview/ | https://pocketbase.io/docs/go-overview/
Extend PocketBase with custom hooks and routes in JS or Go.
Drop *.pb.js files in pb_hooks/:
// pb_hooks/myhook.pb.js
/// <reference path="../pb_data/types.d.ts" />
router.api.post('/custom-route', async (e) => {
const body = e.request.body
// ... process
return e.json({ result: 'ok' })
})
// On record create
onRecordCreateRequest((e) => {
if (!e.record.get('email').endsWith('@company.com')) {
return e.badRequest('Use company email')
}
return e.next()
})
Rules:
e.next() / e.Next() in hooksrequire() for shared config (CJS only, no ESM)Versioned migrations in migrations/:
package migrations
import (
"github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
migrations.Register(func(app *pocketbase.App) error {
// Custom logic
return nil
}, func(app *pocketbase.App) error {
// Rollback logic
return nil
})
}
// Add to pb_hooks
router.api.post('/api/myapp/send-email', async (e) => {
const data = await e.request.json()
await sendEmail(data.to, data.subject)
return e.json({ sent: true })
}, middleware.RequireAuth())
| Event | Purpose |
|---|---|
onRecordCreateRequest | Before record creation |
onRecordUpdateRequest | Before record update |
onRecordDeleteRequest | Before record deletion |
OnRecordEnrich | Shape response (incl. realtime) |
OnRecordRequest | HTTP-only response shaping |
OnBeforeServe | Modify router before serving |
Auto-migrate: Collections changed via Admin UI auto-generate migrations in pb_migrations/
Manual JS migration:
// pb_migrations/1700000000_seed_data.js
migrate((up, down) => {
up((db) => {
db.createCollection('categories', { /* ... */ })
})
down((db) => {
db.dropCollection('categories')
})
})
// Read at runtime
const settings = require('../pb_settings/config.js')
// Access app in hooks
router.use(async (e) => {
const app = e.app
// ...
})