xiaohongshu
xiaohongshu
constitution-guardian
Real-time Constitution compliance checker for devflow documents. Blocks partial implementations and hardcoded secrets during file editing.
Full skill instructions
Enforce CC-DevFlow Constitution compliance by detecting violations in real-time during document editing, preventing non-compliant content from being saved.
Trigger: PreToolUse hook when editing devflow documents (PRD.md, EPIC.md, TASKS.md, TECH_DESIGN.md)
Focus Articles (Real-time prevention):
Note: Full Constitution has 10 Articles. This guardrail focuses on the most critical real-time violations. Batch validation by validate-constitution.sh covers all Articles.
# ❌ BLOCKED
## User Stories
### US1: User Registration
TODO later: Add email verification flow
FIXME: Implement password strength validation
Regex Patterns:
TODO.*laterFIXME\[placeholder\]// TODO:.*later# FIXME:.*# ❌ BLOCKED
## Implementation Notes
This is simplified for now, complete implementation would require...
Regex Pattern: simplified for now
# ❌ BLOCKED
## Acceptance Criteria
- [ ] Basic login (v1)
- [ ] Remember me (defer to v2)
Regex Pattern: defer to v\d|will complete in v\d
# ❌ BLOCKED
## Configuration
API_KEY=sk-abc123def456
JWT_SECRET=mysecretkey123
PASSWORD=admin123
Regex Patterns:
API_KEY\s*=\s*['"]?[a-zA-Z0-9_-]{10,}SECRET\s*=\s*['"]?[a-zA-Z0-9_-]+PASSWORD\s*=\s*['"]?[^\s]+TOKEN\s*=\s*['"]?[a-zA-Z0-9_-]{10,}// ❌ BLOCKED
const config = {
apiKey: "sk-abc123def456",
dbPassword: "postgres123"
};
Regex Patterns:
apiKey:\s*['"][^'"]+['"]password:\s*['"][^'"]+['"]secret:\s*['"][^'"]+['"]When violation detected, PreToolUse hook returns exit code 2 (blocks file save):
⚠️ BLOCKED - Constitution Violation
Detected:
- [Line 42] TODO placeholder (Article I.1 - No Partial Implementation)
- [Line 58] Hardcoded API key (Article III.1 - No Hardcoded Secrets)
📋 ACTION:
1. Complete all TODOs/FIXMEs before saving
2. Move secrets to environment variables (.env, not committed)
3. Review `.claude/rules/project-constitution.md` v2.0.0
4. Run /flow-verify for comprehensive check
Source: Constitution Articles I.1, III.1
File: {file_path}
Constitutional Basis:
Article I.1: "NO PARTIAL IMPLEMENTATION: Complete implementation or no implementation"
Article III.1: "NO HARDCODED SECRETS: Use environment variables or secret management"
💡 SKIP: Add `@constitution-verified` comment or set SKIP_CONSTITUTION_CHECK=1
I.1 Complete Implementation Mandate:
Prohibition: Any form of partial implementation or placeholder code
Requirement: Complete implementation or no implementation
Examples:
❌ Forbidden: "// TODO: Implement this later"
❌ Forbidden: "// Simplified for now, will complete in v2"
✅ Required: Fully functional, production-ready code
Enforcement:
III.1 No Hardcoded Secrets:
Prohibited:
❌ API_KEY = "sk-abc123..." in source code
❌ PASSWORD = "admin123" in config files
❌ JWT_SECRET embedded in code
Required:
✅ Environment variables (.env files, not committed)
✅ Secret management services (AWS Secrets Manager, etc.)
✅ Configuration injection at runtime
Detection: Pre-push guard scans for secret patterns
Enforcement:
Users can bypass Constitution guardian in specific scenarios:
sessionSkillUsed: true in skill-rules.json@constitution-verified comment in document<!-- @constitution-verified: Legacy doc migration, compliance review completed -->
SKIP_CONSTITUTION_CHECK=1Relationship: Complementary (互补)
.claude/rules/project-constitution.md v2.0.0In .claude/skills/skill-rules.json:
{
"constitution-guardian": {
"type": "guardrail",
"enforcement": "block",
"priority": "critical",
"description": "Real-time Constitution compliance, extracted from Constitution v2.0.0",
"fileTriggers": {
"pathPatterns": [
"devflow/requirements/**/PRD.md",
"devflow/requirements/**/EPIC.md",
"devflow/requirements/**/TASKS.md",
"devflow/requirements/**/TECH_DESIGN.md",
"devflow/requirements/**/contracts/**/*.yaml",
"devflow/requirements/**/data-model.md"
],
"contentPatterns": [
"TODO.*later",
"FIXME",
"\\[placeholder\\]",
"simplified for now",
"defer to v\\d",
"API_KEY\\s*=\\s*['\"]?[a-zA-Z0-9_-]{10,}",
"SECRET\\s*=\\s*['\"]?[a-zA-Z0-9_-]+",
"PASSWORD\\s*=\\s*['\"]?[^\\s]+",
"TOKEN\\s*=\\s*['\"]?[a-zA-Z0-9_-]{10,}",
"apiKey:\\s*['\"][^'\"]+['\"]",
"password:\\s*['\"][^'\"]+['\"]"
]
},
"blockMessage": "⚠️ BLOCKED - Constitution Violation\n\nDetected:\n- Partial implementation (Article I.1)\n- Hardcoded secrets (Article III.1)\n\n📋 ACTION:\n1. Complete all TODOs/FIXMEs\n2. Move secrets to config system\n3. Run /flow-verify\n\nSource: .claude/rules/project-constitution.md v2.0.0",
"skipConditions": {
"sessionSkillUsed": true,
"fileMarkers": ["@constitution-verified"],
"envOverride": "SKIP_CONSTITUTION_CHECK"
}
}
}
Goal: Precise violation location reporting
Implementation (in PreToolUse hook):
function detectViolations(content: string, patterns: string[]) {
const lines = content.split('\n');
const violations: Array<{line: number, pattern: string, text: string}> = [];
lines.forEach((line, index) => {
patterns.forEach(pattern => {
if (new RegExp(pattern, 'i').test(line)) {
violations.push({
line: index + 1,
pattern: pattern,
text: line.trim()
});
}
});
});
return violations;
}
Enhanced Blocking Message:
⚠️ BLOCKED - Constitution Violation
Detected 3 violations:
[Line 42] TODO placeholder (Article I.1)
→ "TODO later: Add email verification"
[Line 58] Hardcoded API key (Article III.1)
→ "API_KEY=sk-abc123def456"
[Line 73] FIXME comment (Article I.1)
→ "FIXME: Complete error handling"
📋 ACTION: ...
This guardrail does NOT contain:
This guardrail ONLY contains:
Rationale: Avoid duplication ("不重不漏" principle). Constitution document owns full text, guardrail owns real-time enforcement of critical rules.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience