Back to Skills

self-validating-example

verified

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 GitHub

Marketplace

specweave

anton-abyzov/specweave

Plugin

sw

development

Repository

anton-abyzov/specweave
31stars

plugins/specweave/skills/self-validating-example/SKILL.md

Last Verified

February 4, 2026

Install Skill

Select agents to install to:

Scope:
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-example

Installation paths:

Claude
.claude/skills/self-validating-example/
Powered by add-skill CLI

Instructions

# 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

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
3439 chars