| name | symbolic-guard |
| description | Verify structural validity of formal/symbolic content like SQL, regex, math, schemas, configs, or code logic. Use when: the user invokes /symbolic-guard, generates structured content that must be formally correct, works with complex queries or expressions, or asks to verify a formal structure. Targets: symbolic collapse, constraint hallucination, prose-structure mismatch. |
| user-invocable | true |
Symbolic Guard — Anti-Symbolic-Collapse
You are verifying that formal/structured content is actually correct — not just plausible-sounding. LLMs are prone to generating structured content that reads well as prose but is structurally wrong, silently drops constraints, or hallucinates problem features.
Step 1: Identify Formal Content
List all formal/structured elements in the response being checked:
- SQL queries, ORM expressions
- Regular expressions
- Mathematical formulas or calculations
- JSON/YAML/TOML schemas or configs
- API request/response structures
- Type definitions or interfaces
- Algorithm logic or control flow
- Shell commands or pipelines
Step 2: Syntax Validation
For each formal element:
- Is the syntax valid for its language/format?
- Are all brackets, parentheses, and delimiters balanced?
- Are reserved words and operators used correctly?
- Would this parse without errors?
If possible, mentally (or actually) run the content through a parser. For code, consider running it.
Step 3: Semantic Correctness
- Does the formal content actually do what the prose description says it does?
- Walk through with a concrete example:
- Pick a specific input
- Trace through the formal logic step by step
- Does the output match what the prose promises?
- Are there edge cases where the formal content behaves differently from the prose?
Step 4: Constraint Preservation
Compare the original requirements/constraints with the formal content:
- List each constraint from the requirements
- For each constraint, identify where in the formal content it is enforced
- Flag any constraints that are stated in prose but missing from the formal content
- Flag any constraints that appear in the formal content but weren't in the requirements (hallucinated constraints)
Step 5: Concrete Test Case
Create a specific test case:
- Choose a realistic input
- Show expected output (from requirements)
- Trace actual output (from formal content)
- Do they match?
If they don't match, identify where the formal content diverges.
Step 6: Summary
- Syntax: Valid / Issues at [locations]
- Semantics: Matches prose / Diverges at [points]
- Constraints: All preserved / Missing [list] / Hallucinated [list]
- Test case: Pass / Fail at [step]
Provide corrected formal content if issues were found.