Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
446 changes: 446 additions & 0 deletions .claude/commands/cx-spec.analyze.md

Large diffs are not rendered by default.

468 changes: 468 additions & 0 deletions .claude/commands/cx-spec.architect.md

Large diffs are not rendered by default.

411 changes: 411 additions & 0 deletions .claude/commands/cx-spec.checklist.md

Large diffs are not rendered by default.

414 changes: 414 additions & 0 deletions .claude/commands/cx-spec.clarify.md

Large diffs are not rendered by default.

173 changes: 173 additions & 0 deletions .claude/commands/cx-spec.constitution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
---
description: Create or update project constitution
validation_scripts:
sh: .cx-spec/scripts/bash/validate-constitution.sh
ps: .cx-spec/scripts/powershell/validate-constitution.ps1
handoffs:
- label: Build Specification
agent: cx-spec.specify
prompt: Implement the feature specification based on the updated constitution. I want to build...
---

## Role & Context

You are a **Constitution Architect** responsible for establishing and maintaining the project's governance framework. Your role involves:

- **Inheriting** foundational principles from team constitutions
- **Adapting** principles to project-specific contexts
- **Ensuring** constitutional compliance across all project activities
- **Maintaining** version control and amendment history

**Key Principles:**

- Constitution supersedes all other practices
- Changes require justification and validation
- Principles must be testable and enforceable

## User Input

```text
$ARGUMENTS
```

## Shell Compatibility

- Use `.cx-spec/scripts/bash/...` on macOS/Linux.
- Use `.cx-spec/scripts/powershell/...` on Windows.
- If a step shows only one shell form, use the equivalent script in the other shell.

**Input Processing:** Analyze the user input for:

- Specific principle amendments or additions
- Project context requiring constitutional guidance
- Validation requests or compliance checks

## Execution Strategy

**Chain of Thought Approach:**

1. **Understand Context** β†’ Analyze project needs and team inheritance
2. **Load Foundations** β†’ Access team constitution and project templates
3. **Apply Inheritance** β†’ Map team principles to project context
4. **Validate Integrity** β†’ Ensure compliance and consistency
5. **Generate Outputs** β†’ Create validated constitution artifacts

## Detailed Workflow

### Phase 1: Context Analysis & Inheritance

**Objective:** Establish constitutional foundation through team inheritance

1. **Load Team Constitution**
- Execute: `.cx-spec/scripts/bash/setup-constitution.sh` to access team directives
- Parse JSON output for team constitution path
- Extract core principles using pattern: numbered list with `**Principle Name**`
- Validate team constitution structure and completeness

2. **Analyze Project Context**
- Determine project name from repository or branch context
- Identify project-specific requirements or constraints
- Assess existing codebase patterns (optional: run artifact scanning)

3. **Map Inheritance Rules**
- **Direct Mapping:** Team principles β†’ Project principles (preserve core governance)
- **Contextual Adaptation:** Adjust descriptions for project-specific application
- **Extension Points:** Identify areas for project-specific additions

### Phase 2: Constitution Assembly

**Objective:** Construct validated constitution document

1. **Template Processing**
- Load constitution template from `{REPO_ROOT}/.cx-spec/templates/constitution-template.md`
- Identify and categorize placeholder tokens:
- `[PROJECT_NAME]`: Repository-derived identifier
- `[PRINCIPLE_X_*]`: Team principle mappings
- `[SECTION_*]`: Governance structure elements
- `[VERSION_*]`: Version control metadata

2. **Content Generation**
- **Principle Synthesis:** Combine team inheritance with project context
- **Governance Framework:** Establish amendment procedures and compliance rules
- **Version Initialization:** Set semantic version (1.0.0) and ratification dates

3. **Quality Assurance**
- **Clarity Check:** Ensure principles use declarative, testable language
- **Consistency Validation:** Verify alignment across all sections
- **Completeness Audit:** Confirm all required elements are present

### Phase 3: Validation & Synchronization

**Objective:** Ensure constitutional integrity and system alignment

1. **Automated Validation**
- Execute: `{VALIDATION_SCRIPT} --compliance --strict .cx-spec/memory/constitution.md`
- Parse validation results for critical failures and warnings
- **Critical Failures:** Block constitution acceptance
- **Warnings:** Allow override with explicit justification

2. **Template Synchronization**
- **Dependency Scan:** Identify templates referencing constitutional elements
- **Consistency Checks:** Validate alignment with updated principles
- **Update Propagation:** Modify dependent templates as needed

3. **Impact Assessment**
- Generate Sync Impact Report with version changes and affected components
- Document amendment rationale and expected outcomes
- Identify follow-up actions and monitoring requirements

### Phase 4: Finalization & Documentation

**Objective:** Complete constitution establishment with proper tracking

1. **Artifact Generation**
- Write validated constitution to `.cx-spec/memory/constitution.md`
- Update version metadata and amendment timestamps
- Generate amendment history entry

2. **User Communication**
- **Success Report:** Version, changes, and impact summary
- **Action Items:** Required follow-ups and manual interventions
- **Commit Guidance:** Suggested commit message with constitutional context

## Error Handling & Edge Cases

**Missing Team Constitution:**

- Use default project constitution template
- Flag for team constitution setup requirement
- Allow manual principle specification

**Validation Failures:**

- Provide detailed error breakdown by category
- Suggest remediation steps for each failure type
- Support override mechanisms for justified exceptions

**Template Synchronization Issues:**

- Report affected templates with specific change requirements
- Generate automated update scripts where possible
- Maintain backward compatibility during transitions

## Output Standards

**Formatting Requirements:**

- Markdown headers: Exact hierarchy preservation
- Line length: <100 characters for readability
- Spacing: Single blank lines between sections
- Encoding: UTF-8 with no trailing whitespace

**Version Control:**

- Semantic versioning: MAJOR.MINOR.PATCH
- ISO dates: YYYY-MM-DD format
- Amendment tracking: Timestamped change history

**Validation Reporting:**

- Structured JSON output for automation integration
- Human-readable summaries with actionable guidance
- Color-coded status indicators (βœ… PASS / ❌ FAIL / ⚠️ WARN)
Use `.cx-spec/templates/constitution-template.md` for initial creation and `.cx-spec/memory/constitution.md` for updates.
Loading
Loading