skills/openspec-constitution-guard/SKILL.md
This skill composes project AGENTS.md constitution files into openspec/config.yaml to inject quality validation gates into OpenSpec workflows. Use this skill when initializing openspec for the first time in a project or when AGENTS.md files are updated. The skill ensures openspec artifacts are validated against project-specific quality criteria from constitutions.
npx skillsauth add cyberelf/agent_skills openspec-constitution-guardInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill ensures OpenSpec workflows enforce project-specific quality assurance criteria derived from AGENTS.md constitution files by injecting them into openspec/config.yaml.
OpenSpec workflows (/opsx:apply, /opsx:verify, /opsx:archive, etc.) include generic validation. This skill enriches them with project-specific quality gates extracted from AGENTS.md files across the workspace, ensuring all artifacts pass the project's defined testing and QA criteria before handoff.
Trigger this skill when:
openspec init)To detect if guards need composition:
openspec/config.yaml exists<!-- CONSTITUTION-GUARD:START marker in the config fileLast Updated date → refresh neededFind all AGENTS.md files in the workspace:
find . -name "AGENTS.md" -type f | grep -v node_modules | grep -v .venv | grep -v target | grep -v openspec/AGENTS.md
Exclude openspec/AGENTS.md as it contains OpenSpec usage instructions already referenced by the system, not project-specific quality criteria.
Read each remaining file to understand its scope (root project, backend, frontend, specific module, etc.).
For each AGENTS.md file, identify sections related to quality assurance. Look for:
Key information to extract:
pytest, npm run lint)Map the extracted criteria to specific OpenSpec artifacts in the config.yaml rules:
proposal ArtifactExtract rules that validate design decisions:
specs ArtifactExtract rules that validate specification quality:
design ArtifactExtract rules that validate technical design:
tasks ArtifactExtract rules that validate implementation planning:
Extract information that should be available to all artifacts:
Create or update openspec/config.yaml with the constitution guards. The file should include:
Template structure:
# openspec/config.yaml
# Schema selection (if you have a preferred one)
schema: spec-driven
# <!-- CONSTITUTION-GUARD:START - Auto-generated from AGENTS.md files -->
# Context injected into ALL artifacts
context: |
[PROJECT-WIDE CONTEXT]
# Per-artifact validation rules
rules:
proposal:
- [PROPOSAL-SPECIFIC RULES]
specs:
- [SPECS-SPECIFIC RULES]
design:
- [DESIGN-SPECIFIC RULES]
tasks:
- [TASKS-SPECIFIC RULES]
# Constitution metadata
# Source Constitutions:
# - [List each AGENTS.md file path]
# Last Updated: [YYYY-MM-DD]
# <!-- CONSTITUTION-GUARD:END -->
openspec/config.yaml exists
<!-- CONSTITUTION-GUARD:START markerschema: declaration at the topCritical: Always validate YAML syntax after generation to ensure the file is parseable.
After reading constitutions with Python backend and TypeScript frontend:
# openspec/config.yaml
schema: spec-driven
# <!-- CONSTITUTION-GUARD:START - Auto-generated from AGENTS.md files -->
# Context injected into ALL artifacts
context: |
Tech stack: Python (FastAPI, Pydantic), TypeScript (React, Node.js), PostgreSQL
Architecture: Service layer pattern - business logic in services/, API routes are thin
Type safety: Strict typing required (no Any/any types)
API style: RESTful with OpenAPI docs
Testing: pytest + React Testing Library
We value backwards compatibility for all public APIs
# Per-artifact validation rules
rules:
proposal:
- Include rollback plan for breaking changes
- Mark breaking changes with **BREAKING** prefix
- Identify affected teams/systems
- Verify alignment with service layer architecture
specs:
- Use Given/When/Then format for scenarios
- Document all edge cases and error conditions
- Reference existing patterns before proposing new ones
- Include API contract changes if applicable
design:
- Maintain service layer separation (logic in services/, not api/)
- Use Pydantic models for all new data structures
- Ensure strict typing (no Any types in Python/TypeScript)
- Document integration points with existing services
tasks:
- Include unit test tasks for all new service logic
- Include integration test tasks for API changes
- Add type checking verification tasks
- Include documentation update tasks
# Source Constitutions:
# - AGENTS.md
# - backend/AGENTS.md
# - frontend/AGENTS.md
# Last Updated: 2026-02-09
# <!-- CONSTITUTION-GUARD:END -->
After reading constitutions with specific test commands:
# openspec/config.yaml
schema: spec-driven
# <!-- CONSTITUTION-GUARD:START - Auto-generated from AGENTS.md files -->
context: |
Tech stack: Python (uv, FastAPI), TypeScript (Vite, React), PostgreSQL
Automated checks required before completion:
- Python: uv run pytest, uv run ruff check ., uv run pyright .
- TypeScript: npm run lint, npm run tsc, npx playwright test
Architecture: Microservices with event-driven communication
All services must be independently deployable
rules:
proposal:
- Identify service boundaries affected
- Document event schema changes
- Include deployment strategy
- Consider backwards compatibility for events
specs:
- Document event payloads in Given/When/Then scenarios
- Include failure/retry scenarios
- Specify service dependencies
design:
- Show event flow diagrams for cross-service changes
- Use async/await patterns for I/O operations
- Maintain service independence
tasks:
- Before marking complete, run: uv run pytest (Python)
- Before marking complete, run: npm run lint && npm run tsc (TypeScript)
- Include E2E test tasks for cross-service scenarios
- Add event contract validation tasks
# Source Constitutions:
# - AGENTS.md
# - services/user/AGENTS.md
# - services/order/AGENTS.md
# Last Updated: 2026-02-09
# <!-- CONSTITUTION-GUARD:END -->
After reading constitutions from root, backend (Python), frontend (React), and mobile (Swift):
# openspec/config.yaml
schema: spec-driven
# <!-- CONSTITUTION-GUARD:START - Auto-generated from AGENTS.md files -->
context: |
Multi-platform project with shared API
Backend (Python):
- FastAPI + SQLAlchemy + Alembic
- Service layer required for all business logic
- Commands: uv run pytest, uv run ruff check ., uv run mypy .
Web Frontend (TypeScript/React):
- Vite + React + TanStack Query
- Commands: npm run lint, npm run type-check, npm test
Mobile (Swift):
- SwiftUI + Combine
- Commands: swift test, swiftlint
Shared API contracts documented in docs/api/
Zero tolerance for breaking changes without migration plan
rules:
proposal:
- Mark platform scope (backend/web/mobile/api)
- For API changes, document impact on all clients
- Include migration strategy for breaking changes
- Specify API versioning approach if needed
specs:
- Use platform-specific scenario tags: [Backend], [Web], [Mobile]
- Document API contract changes in OpenAPI format
- Include backwards compatibility scenarios
- Reference existing patterns from project codebase
design:
- Show component/service interaction diagrams
- Maintain service layer in backend (no logic in routes)
- Use proper state management patterns per platform
- Document data flow for cross-platform features
tasks:
- Group tasks by platform with clear labels
- Backend: Include pytest, ruff, mypy verification
- Web: Include lint, type-check, unit test tasks
- Mobile: Include SwiftLint and unit test tasks
- For API changes, include contract validation task
- Include platform-specific E2E test tasks
# Source Constitutions:
# - AGENTS.md
# - backend/AGENTS.md
# - frontend/AGENTS.md
# - mobile/AGENTS.md
# Last Updated: 2026-02-09
# <!-- CONSTITUTION-GUARD:END -->
When reading AGENTS.md files with varying structures:
For Context (applies to all artifacts):
For Rules (specific to artifacts):
If a constitution section is ambiguous, interpret conservatively—include the check rather than omit it.
All constitution items should be derived from project AGENTS.md files only, DO NOT include OpenSpec's own AGENTS.md or any common sense or best practices from other materials.
When an OpenSpec command generates or works with an artifact, your configuration is automatically injected:
<context>
Tech stack: Python (FastAPI, Pydantic), TypeScript (React, Node.js), PostgreSQL
Architecture: Service layer pattern - business logic in services/, API routes are thin
Type safety: Strict typing required (no Any/any types)
...
</context>
<template>
[Schema's built-in template for this artifact]
</template>
For /opsx:continue proposal or when generating a proposal:
<rules>
- Include rollback plan for breaking changes
- Mark breaking changes with **BREAKING** prefix
- Identify affected teams/systems
- Verify alignment with service layer architecture
</rules>
This ensures every artifact is generated with your project's specific requirements in mind.
Understanding which commands work with which artifacts:
| Command | Purpose | Affected Artifacts |
|---------|---------|-------------------|
| /opsx:new | Start a change | Creates change directory |
| /opsx:continue | Create next artifact | proposal → specs → design → tasks |
| /opsx:ff | Fast-forward (create all planning) | proposal, specs, design, tasks |
| /opsx:apply | Implement tasks | Works from tasks.md |
| /opsx:verify | Validate implementation | Checks against all artifacts |
| /opsx:sync | Merge specs to main | Updates openspec/specs/ |
| /opsx:archive | Complete change | Finalizes and archives |
Your constitution rules in config.yaml affect the quality and validation of artifacts throughout this workflow.
When updating guards:
<!-- CONSTITUTION-GUARD:START block in config.yamlschema: declaration at the topLast Updated timestampopenspec new test-change to verify configuration loads correctlyAfter updating config.yaml, verify it works:
# Check YAML syntax
python -c "import yaml; yaml.safe_load(open('openspec/config.yaml'))"
# Test with a dummy change
openspec new test-validation
# Check if context and rules are properly injected in artifacts
If you see errors about context or rules not being injected, check YAML indentation and structure.
tools
Agent-first graph-backed knowledge wiki builder with a self-contained CLI. Use for Graphwiki init/build/ingest/update, source indexing, semantic entity and relationship extraction, generated wiki pages, graph JSON/HTML explorer, evidence line ranges, query/explain question answering, synthesis pages, HTML reports, adding confirmed entity types, applying patches, cleanup, validation, tasks, and SQLite cache generation.
development
Use when the user asks to export a local HTML file, web page, or invitation page to a single-page PDF, a no-pagination PDF, a long PDF with auto-calculated height, or a PDF without headers and footers. Trigger on phrases like 单页 PDF, 不分页, 自动计算长度, 长图 PDF, 去掉页眉页脚, export HTML to single-page PDF, or print page to one PDF page.
development
Build and expand an insight-ready raw-material layer by discovering page-level sources, deduplicating them with an internal pre-crawl link index, capturing raw Markdown, verifying metadata in place, and keeping ingest/register state aligned. Use for additive source harvesting, raw webpage capture, source registry maintenance, source/ingest tracking, source/raw downloads, and in-place verification rather than final synthesis.
development
Generate a structured, illustrated Q&A HTML document from the current conversation. Scans the conversation for conceptual questions the user asked and Claude's answers, then produces a self-contained HTML file with styled cards and SVG diagrams for technical/architectural topics. If a Q&A HTML file already exists in the current project directory, appends the new Q&As to it instead of creating a new file. Trigger this skill whenever the user asks to "generate Q&A", "create Q&A from conversation", "save Q&A", "document our Q&A", "turn this chat into Q&A", or anything suggesting they want the conversation's questions and answers captured as a document — even if they don't use the exact phrase "Q&A skill".