server-actionlisted
Install: claude install-skill rajurayhan/ai-agent-framework
# Server Action / Mutation Handler
## Inputs
1. Feature name (e.g. expenses, transfers, leave)
2. Permission key (e.g. `finance.expense.approve`)
3. Self-service scoped? (caller must own record)
4. Touches money? (audit log required)
## Steps
1. **Write failing integration test**
- Permission denied
- Self-service scope denied (if applicable)
- Success + audit log assertion
- Domain: immutability/idempotency if applicable
2. Create/update validation schema (e.g. Zod)
3. Implement handler:
- Validate input
- Resolve actor → require permission / scope check
- Mutate via server-only data layer
- Write audit log if money/permission-touching
4. Wire UI form to handler; handle loading/errors
5. Run tests green
## File layout (adapt to your stack)
```
src/features/<feature>/
actions.ts / handler.ts
schema.ts
<feature>-form.tsx
src/lib/<domain>/
<domain>-repo.ts
tests/integration/mutations/<feature>/
<action-name>.test.ts
```
## Domain-specific
- Never edit immutable/processed records in place
- Manual adjustments → itemized records with reason, actor, timestamp
- Long-running processing → enqueue background job, don't compute inline
## Checklist
- [ ] Failing integration test written before handler (permission, scope, success + audit)
- [ ] Shared validation schema (client + server)
- [ ] Permission + self-service scope check before DB access
- [ ] Server-only data layer — no client privileged queries
- [ ] Audit log on money/permission mu