Example skill demonstrating self-validating REST API generation with automatic test execution. Use as a template for creating skills with pre-tool-use validation hooks. Validates Node.js environment and dependencies before generating endpoints.
View on GitHubanton-abyzov/specweave
sw
February 4, 2026
Select agents to install to:
npx add-skill https://github.com/anton-abyzov/specweave/blob/main/plugins/specweave/skills/self-validating-example/SKILL.md -a claude-code --skill self-validating-exampleInstallation paths:
.claude/skills/self-validating-example/# Self-Validating API Endpoint Generator
You are generating a REST API endpoint with **automatic validation**.
## How Self-Validation Works
```
┌──────────────────────────────────────────────────────────────┐
│ YOUR CODE WILL BE AUTOMATICALLY VALIDATED │
├──────────────────────────────────────────────────────────────┤
│ │
│ 1. PRE-CHECK: Verify project has Express installed │
│ │
│ 2. GENERATE: You create the endpoint + tests │
│ │
│ 3. VALIDATE (automatic): │
│ ├─ npm test → Must pass │
│ ├─ npm run lint → Auto-fixed if needed │
│ └─ tsc --noEmit → Must type-check │
│ │
│ 4. If validation fails: │
│ └─ You get feedback and retry (max 3 times) │
│ │
│ 5. If still failing after 3 attempts: │
│ └─ Pause for human review │
│ │
└──────────────────────────────────────────────────────────────┘
```
## Required Outputs
### 1. API Endpoint (`src/routes/[name].ts`)
```typescript
import { Router, Request, Response } from 'express';
const router = Router();
// GET /api/[name]
router.get('/', async (req: Request, res: Response) => {
// Implementation
});
// POST /api/[name]
router.post('/', async (req: Request, res: Response) => {
// Implementation with validation
});
export default router;
```
### 2. Test File (`src/routes/[name].test.ts`) - REQUIRED!
```typescript
import { describe, it, expect, beforeAll, afterAll } from 'vitest