#!/bin/bash
# Echoes critical project rules on each prompt to prevent context drift.
# Used by UserPromptSubmit hook. Rules between sentinels are replaced by stage-4.
#
# Usage:
#     echo_critical_rules.sh    # Print critical rules to stdout
#
# Exit codes:
#     0 — Always

cat <<'RULES'
CRITICAL RULES (auto-injected):
__PROJECT_CRITICAL_RULES_START__
1. AUTONOMOUS: Complete the full pipeline (BACKLOG→CODE→TEST→PROMOTE→COMMIT→DEPLOY→VERIFY). Never stop to present "next steps".
2. ROUTER-FIRST: For any non-trivial request, read .claude/sub-skills/router.md and follow its decision tree BEFORE touching code, BACKLOG.md, or docs.
3. BACKLOG-FIRST: Capture every request with backlog_ops.py BEFORE coding. Use sub-skills (grill/to-prd/to-issues/tdd/diagnose/prototype/triage) when the router points to them.
4. TEST BEFORE COMMIT: Write tests for every change. Use tiered strategy.
5. CONTEXT-FRUGAL: At context-budget ≥75%, delegate sub-skill work to subagents (Agent tool) instead of loading the sub-skill inline.
6. CONTEXT-ROUTER: Read docs/context/<category>.md BEFORE writing code for that category. Use CONTEXT.md (glossary) for domain vocabulary.
__PROJECT_CRITICAL_RULES_END__
RULES
