---
name: validate
description: Validate spec/ files against naming and audience-scope rules
arguments: "[FILE-PATH...]"
---

# /spec:validate Command

Validate spec/ directory files against file naming conventions and audience-scope content rules defined in the project's spec/ reference files.

## Purpose

The `/spec:validate` command ensures compliance by:
- Validating file naming conventions (prd-*, ops-*, dev-*)
- Detecting code examples in PRD files (prohibited)
- Validating content scope matches file type

Requirement format validation (REQ IDs, hierarchy, orphans) is handled by **elspais** (`anspar-wf validate`).

## Usage

```bash
/spec:validate                             # Validate all spec/*.md files
/spec:validate spec/prd-authentication.md  # Validate specific file
/spec:validate spec/prd-*.md               # Validate all PRD files
```

## Arguments

### `FILE-PATH` *(optional, multiple allowed)*

Path(s) to spec files to validate:
- Default: All `spec/*.md` files
- Supports glob patterns
- Multiple files can be specified

## Validation Rules

**All spec files**:
- Filename matches pattern: `{prd|ops|dev}-{topic}(-{subtopic}).md`
- Lowercase audience prefix required

**PRD files** (`prd-*.md`):
- NO code blocks with language tags (```python, ```sql, etc.)
- Plain ``` blocks allowed (ASCII diagrams)
- Suspicious inline code flagged as warning (SQL keywords, API paths)

**Ops files** (`ops-*.md`):
- CLI commands and configuration allowed

**Dev files** (`dev-*.md`):
- Code examples allowed and encouraged

## Examples

### Validate All Spec Files

```bash
/spec:validate

# Output:
# Validating spec/ files...
#
# Validating: spec/prd-authentication.md
#   Passed
# Validating: spec/ops-deployment.md
#   Passed
# Validating: spec/dev-database.md
#   Passed
#
# All validations passed!
```

### Validation Failure

```bash
/spec:validate spec/prd-authentication.md

# Output:
# Validating: spec/prd-authentication.md
#   Invalid filename format: product-auth.md
#     Expected: {audience}-{topic}(-{subtopic}).md
#   PRD file contains code blocks (forbidden)
#     Line 45: ```python
#     Action: Remove all code blocks with language tags
#     Run: claude /remove-prd-code
#
# Validation failed. Fix violations before committing.
```

## Exit Codes

- `0` - All validations passed
- `1` - Validation failures found
- `2` - Script error (spec/README.md not found)

## Related

- **spec/README.md** - Directory purpose and high-level rules
- **spec/requirements-spec.md** - Authoritative requirement grammar and structure
- **spec/AI-AGENT.md** - AI agent constraints for requirement authoring
- **`anspar-wf validate`** - Requirement format validation (elspais)
- **/remove-prd-code** - Remove code from PRD files

## Implementation

```bash
bash ${CLAUDE_PLUGIN_ROOT}/../spec-compliance/scripts/validate-spec-compliance.sh "$@"
```
