← All Examples
Implementation Example

AI Prompting with Semantic Intent

Traditional prompting yields generic responses. Semantic intent prompting delivers precise, pattern-aware assistance — 10x faster problem identification.

The Difference

A traditional prompt like "Fix the PDF generation bug where both files have the same size" sends the AI on a generic exploration. A semantic intent prompt gives it the architectural context to identify the violation immediately.

Traditional Prompt
"Fix the PDF generation bug where both files have the same size"

→ Generic exploration
→ Missed semantic violations
→ 2-4 hours of exploratory debugging
Semantic Intent Prompt
SEMANTIC INTENT: Preserve document type semantics through
                 transformation layers
VIOLATION: analysisDepth overriding document type intent
ANCHOR: title.includes('executive') → executiveVersion: true

→ Immediate pattern recognition
→ Instant fix identification
→ 15-30 minutes to solution

Pattern 1: Semantic Contract

Structure your prompts with explicit semantic anchors, domain boundaries, and expected behaviors. The AI immediately understands what should drive behavior and what should not.

SEMANTIC INTENT: Document type semantics must drive content generation

SEMANTIC ANCHORS:
- title.includes('executive') → condensed content generation
- title.includes('comprehensive') → detailed content generation

DOMAIN BOUNDARIES:
- Document Domain OWNS: document type semantics, content behavior
- Analysis Domain OWNS: processing complexity, technical parameters
- Analysis Domain PROHIBITS: overriding document type intent

EXPECTED BEHAVIOR:
- Executive documents → 9-12 pages (condensed)
- Comprehensive reports → 20-30 pages (detailed)

Pattern 2: Immutable Governance

When you need protection mechanisms for semantic contracts, tell the AI exactly what cannot be violated and how violations should be detected.

GOVERNANCE REQUIREMENT: API route semantic intent preserved
                       through middleware

IMMUTABLE CONTRACTS:
- routeSemanticIntent.userIntent → authentication requirements
- routeSemanticIntent.dataIntent → validation and sanitization
- routeSemanticIntent.responseIntent → format and caching

PROTECTION MECHANISM:
const protectedRouteIntent = Object.freeze({
  userIntent: deriveUserSemantics(route),
  dataIntent: deriveDataSemantics(route),
  responseIntent: deriveResponseSemantics(route)
});

Pattern 3: Debugging Violations

For bug investigations, structure the prompt as a hypothesis about which semantic contract is broken, with the expected flow and detection strategy.

SEMANTIC VIOLATION HYPOTHESIS:
  Query performance issues due to semantic intent mismatch

EXPECTED SEMANTIC FLOW:
  User Request → Business Intent Derivation
    → Query Semantic Intent → Optimized Query

VIOLATION DETECTION STRATEGY:
  - Add semantic intent logging at each layer
  - Compare expected vs actual semantic transformations
  - Identify where business intent gets lost

SEMANTIC RESTORATION APPROACH:
  const querySemanticIntent = {
    userType: 'premium_customer',
    dataNeeds: 'real_time_analytics',
    expectedPerformance: 'sub_100ms'
  };
  const optimizedQuery = buildSemanticQuery(querySemanticIntent);

Impact

10x
Faster problem identification
90-95%
Pattern recognition accuracy
0-1
Violations per interaction