Defines the rules used by /architect:validate-consistency to detect conflicts across project outputs
Consistency Rules Skill
Defines the 23 rules used by /architect:validate-consistency to detect conflicts across project outputs. These rules are the "law of the land" for cross-command consistency.
Rule Catalog
The 23 rules are divided into three categories:
State Rules (6) — Validate individual fields in _state.json
Output Rules (8) — Validate files generated by individual commands
Cross-Command Rules (9) — Detect conflicts between outputs of different commands
State Rules (RULE-S-xxx)
Validate that fields in _state.json follow the canonical schema and contain sensible values.
RULE-S-001: Design colors must be valid hex
Rule: Every field under _state.json.design that ends with a color name (primary, secondary, accent, surface, text_primary, text_secondary, etc.) must be a valid hex color code in format #RRGGBB.
Auto-fixable: Yes (add # prefix or reject invalid)
RULE-S-002: Component ports must be unique and numeric
Rule: Every component in _state.json.components[] must have a unique port number. Ports must be integers in range 1024-65535. No two components can share the same port.
Check:
components.forEach(c => {
if (typeof c.port !== 'number') throw"PORT_NOT_NUMBER";
if (c.port < 1024 || c.port > 65535) throw"PORT_OUT_OF_RANGE";
});
if (newSet(components.map(c => c.port)).size !== components.length) {
throw"DUPLICATE_PORT";
}
Examples:
✅ Components: api-server (3000), web-app (3001), worker (5000) — all unique, all valid
❌ Two components on port 3000 — duplicate
❌ Component port "3000" (string) — not numeric
❌ Component port 999 — below 1024
Severity: Critical (port collisions block local dev)
Auto-fixable: Partial (can detect, requires user to reassign)
RULE-S-003: Entity names must match schema if schema exists
Rule: Every entity name in _state.json.entities[] must have a corresponding type definition in the data model schema. If schema exists (schema.prisma, etc.), all entities must be defined there.
✅ State has User, Product; schema has User, Product — match
❌ State has User, Product, Order; schema has User, Product — Order missing from schema
✅ No schema exists — skip this rule
Severity: Warning (incomplete schema, future code gen problems)
Auto-fixable: No (requires investigation: add entity to schema or remove from state)
RULE-S-004: Tech stack versions must be valid semver
Rule: All version strings in _state.json.tech_stack (e.g., "Node.js 18", "Next.js 14", "PostgreSQL 15") must parse as valid semantic versioning (MAJOR.MINOR.PATCH) or be underspecified (MAJOR or MAJOR.MINOR).
RULE-S-005: Persona and decision IDs must be unique
Rule: Every ID in _state.json.personas[] and _state.json.decisions[] must be unique within its array. IDs are user-facing keys for tracking decisions and personas.
Auto-fixable: No (requires renumbering, which affects references)
RULE-S-006: All referenced fields must exist
Rule: If one field in _state.json references another field (e.g., an entity references a field name), that reference must resolve. Common referential integrity checks:
entities[].fields[] must be strings (field names)
risk_register[].mitigations[] must reference actual mitigation strategies
personas[].pain_points[] must be defined (no null/undefined)
Check:
entities.forEach(entity => {
entity.fields.forEach(field => {
if (typeof field !== 'string' || !field) throw"INVALID_FIELD_NAME: " + entity.name;
});
});
// Example: if personas reference skills, verify skills exist
personas.forEach(p => {
p.skills?.forEach(skill => {
if (!availableSkills.includes(skill)) throw"SKILL_NOT_FOUND: " + skill;
});
});
Examples:
✅ Entity User has fields: [id, email, name, role] — all strings
❌ Entity User has fields: [id, 123, name] — 123 is not a string
✅ Persona references skill "procurement" and that skill is defined
❌ Persona references skill "unknown_skill" which doesn't exist
Severity: Warning (broken references cause issues downstream)
Auto-fixable: Partial (can remove broken references with warning)
Output Rules (RULE-O-xxx)
Validate that individual command outputs are internally consistent and match expectations.
RULE-O-001: Design tokens file must match _state.json colors
Rule: The design-system/design-tokens.json file must have the same color values as _state.json.design. These should be identical (no rounding, no color space conversion).
Auto-fixable: Partial (can prompt user which source is correct)
Root cause: Usually design-system command ran with old state, or state was updated after design-system ran.
RULE-O-002: Scaffold files must match component definitions
Rule: Every component defined in _state.json.components[] must have corresponding files in the scaffold directory. Component name must match folder/file naming (kebab-case).
RULE-O-003: Cost estimate must be based on current component count
Rule: The cost estimate (if generated) must reference the current component count from _state.json. If state has N components but cost-estimate was run with M components (where M ≠ N), flag as stale.
Auto-fixable: No (requires rerunning /architect:cost-estimate)
RULE-O-004: Test coverage percentage must be 0-100%
Rule: Any field in test outputs that reports coverage (test_suite.coverage%, test_suite.coverage_target%) must be a number between 0 and 100. No negative percentages, no >100%.
RULE-O-005: Compliance rules must reference existing entities or patterns
Rule: Each compliance control in a compliance report must reference real entities (from _state.json.entities[]) or architectural patterns that actually exist in the scaffold.
RULE-O-006: Monitoring metrics must align with tech stack
Rule: Monitoring outputs (dashboards, metrics, alerts) must reference services/frameworks that are actually in the tech stack. Can't monitor "Kafka" if tech stack doesn't include Kafka.
✅ Docs reference "api-server" and that component exists in _state.json
❌ Docs reference "legacy-service" which no longer exists
Severity: Info (documentation outdated, confusing but not blocking)
Auto-fixable: No (requires updating docs)
Cross-Command Rules (RULE-X-xxx)
Detect conflicts between outputs of different commands. These are the most important rules for catching architectural drift.
RULE-X-001: No component should exist in both created and deleted lists
Rule: If a component was created by /architect:scaffold-component, it shouldn't appear in any "removed components" or "deprecated" list. A component can't exist and not exist.
Check:
const created = activity.filter(a => a.phase === 'scaffold-component').map(a => a.component);
const removed = state.deprecated_components || [];
const both = created.filter(c => removed.includes(c));
if (both.length > 0) throw"COMPONENT_IN_BOTH_CREATED_AND_REMOVED: " + both;
Examples:
✅ Scaffold created auth-service, remove list is empty — consistent
❌ Scaffold created auth-service, remove list contains auth-service — contradiction
Severity: Critical (architectural confusion)
Auto-fixable: No (requires deciding to keep or remove component)
RULE-X-002: Design personality must be consistent across scaffold and design-system
Rule: The design personality chosen in _state.json.design.personality must be used consistently across the scaffold. If state says "bold-commercial", scaffold component names and structure should reflect that personality (not "serene-health" or other personality).
Auto-fixable: No (requires aligning design direction)
RULE-X-003: Entity count must increase or stay same, never decrease
Rule: As the project evolves, the entity count in _state.json.entities[] should only increase or stay the same. It should never decrease (would indicate entities were deleted, which is a major architecture change that should be audited).
Severity: Critical (indicates major refactor that should be tracked)
Auto-fixable: No (requires investigation)
RULE-X-004: Blueprint architecture must match scaffold service layout
Rule: The services/components described in the blueprint must match the actual scaffolded components. If blueprint says "api-server, web-app, worker", scaffold must have those 3 components (not 2 or 4).
✅ Blueprint describes api-server, web-app, worker; scaffold has all 3
❌ Blueprint describes api-server, web-app, worker; scaffold only has api-server and web-app (missing worker)
Severity: Warning (architectural mismatch, confusing for developers)
Auto-fixable: No (requires deciding which is correct)
RULE-X-005: Tech stack languages must match codebase
Rule: Languages listed in _state.json.tech_stack.backend and .frontend must match the actual programming languages found in the scaffolded source code.
Severity: Warning (tech stack and codebase are out of sync)
Auto-fixable: No (requires investigation)
RULE-X-006: Monitoring provider must be listed in tech stack integrations
Rule: The observability provider chosen in monitoring setup (Datadog, New Relic, Prometheus, etc.) must be listed in _state.json.tech_stack.integrations[].
Severity: Medium (missing from tech stack list, but monitoring will still work)
Auto-fixable: Yes (add provider to integrations)
RULE-X-007: Compliance frameworks must be supported by tech stack
Rule: Each compliance framework in the compliance plan (GDPR, SOC 2, HIPAA, etc.) must be achievable with the chosen tech stack. Some tech stacks can't support certain compliance frameworks (e.g., free tier services can't do HIPAA).
❌ Framework = HIPAA, tech_stack uses free-tier only services — not achievable
❌ Framework = GDPR + data residency in EU, tech_stack only has US deployments — not achievable
Severity: Critical (compliance impossible with current tech stack)
Auto-fixable: No (requires changing tech stack or compliance requirements)
RULE-X-008: Load test target RPS must be realistic for tech stack
Rule: The target requests-per-second (RPS) in load testing must be achievable with the chosen tech stack. Don't target 10k RPS if using a single-threaded framework.
Severity: Warning (load test goals are unachievable)
Auto-fixable: No (requires adjusting tech stack or RPS targets)
RULE-X-009: All referenced external services must exist in tech stack
Rule: Any external service referenced in blueprints, architecture diagrams, or data flow (Stripe, Auth0, SendGrid, etc.) must be listed in _state.json.tech_stack.integrations[].
✅ Blueprint mentions Stripe for payments, tech_stack.integrations includes "Stripe" — match
❌ Blueprint mentions Auth0, tech_stack.integrations is empty or doesn't list Auth0 — missing
Severity: Medium (integration incomplete, but not blocking)
Auto-fixable: Yes (add to integrations)
Using These Rules
In /architect:validate-consistency
for each rule in [RULE-S-001 through RULE-X-009]:
result = apply_rule(rule, state, outputs)
if result === FAIL:
conflict = {
rule_id: rule.id,
severity: rule.severity,
description: rule.description,
remediation: rule.auto_fixable ? "can fix" : "manual fix needed"
}
add conflict to report
In error messages
When a user runs a command and hits a rule violation, show them:
Which rule failed (RULE-X-009)
What it means in plain English
How to fix it
Why it matters
Example:
❌ RULE-X-009 violation: "Stripe" is referenced in blueprint but not listed in tech stack integrations.
This means: Your blueprint includes Stripe for payments, but I can't find "Stripe" in the integrations list.
Fix: Add "Stripe" to _state.json.tech_stack.integrations
Why: Keeping integrations in sync helps with cost estimation, security scanning, and deployment configuration.
Rule Maintenance
When to add a new rule
Add a new rule when you find:
A conflict that happened to 3+ projects (not a one-off)
A conflict that's expensive to fix (worth preventing)
A conflict that's systematic (not human error)
Process:
Create rule with clear name, check logic, examples
Add to appropriate category (State/Output/Cross-Command)
Test on 2-3 projects to validate
Document severity and auto-fix capability
Add to consistency-rules/SKILL.md
When to deprecate a rule
Deprecate (don't delete) a rule when:
It becomes irrelevant (technology changed)
A different rule subsumes it
It's too noisy (more false positives than real issues)
Process:
Mark as DEPRECATED in rule definition
Continue to report violations but with low severity
Document why deprecated and what replaces it
Keep rule in doc for historical reference
Related Commands
/architect:validate-consistency — applies all these rules
/architect:check-state — validates state schema (overlaps with State rules)
/architect:next-steps — considers consistency when recommending commands
/architect:production-readiness — blocks launch if critical rules fail