Skip to main content
πŸ’‘Explanation

Standards: Pattern Discovery Through RAG

This page explains how standards create knowledge compounding in prAxIs OS through automatic pattern discovery via semantic search.

What you'll understand:

  • How standards enable automatic pattern discovery
  • The self-improving mechanism
  • RAG indexing and discovery
  • The compounding effect over time
  • Why AI-authored standards work better

What Are Standards?​

Standards are reusable patterns documented in markdown files that AI agents discover automatically through semantic search.

Location: .praxis-os/standards/development/[topic].md

Access: search_standards("pattern")

Purpose: Make project-specific conventions discoverable and automatically applied


The Problem Standards Solve​

Without Standards: Reinvention and Inconsistency​

Scenario: Three AI Agents, Same Project

Agent 1 (Week 1):

  • Implements authentication with custom JWT refresh pattern
  • Makes architectural decisions about token storage
  • Completes the work
  • Learning is lost ❌

Agent 2 (Week 3):

  • Needs to implement authorization
  • Queries standards, finds only universal patterns
  • Makes different decisions about token handling
  • Creates inconsistency in the codebase ❌

Agent 3 (Week 5):

  • Debugging auth issues
  • Finds two different JWT patterns in code
  • Wastes time investigating which is "correct"
  • No single source of truth ❌

Result: Reinvention, inconsistency, technical debt.


With Standards: Discovery and Consistency​

Same Scenario With Standards

Agent 1 (Week 1):

  • Implements authentication with custom JWT refresh pattern
  • Human: "We should document this as a standard"
  • Agent queries: search_standards("how to create standards")
  • Creates: .praxis-os/standards/development/authentication.md
  • Learning is captured βœ…

Agent 2 (Week 3):

  • Needs to implement authorization
  • Queries: search_standards("JWT authentication patterns")
  • RAG returns Agent 1's documented standard
  • Follows the established pattern automatically
  • Consistency maintained βœ…

Agent 3 (Week 5):

  • Working on auth features
  • Queries standards, finds documented pattern
  • Uses authoritative project convention
  • Single source of truth βœ…

Result: Consistency, velocity, compound knowledge.


How the Mechanism Works​

1. AI Queries Heavily (5-10+ Times Per Task)​

πŸ€–
AI starting new task
↓
πŸ”
Queries: search_standards("how to X")
↓
πŸ“š
Discovers patterns
↓
✨
Implements using established patterns
↓
AI always queries before implementing. This is the foundation of the system.

Key: AI always queries before implementing. This is the foundation of the system.


2. Human Identifies Reusable Patterns​

As work progresses, you notice patterns worth documenting:

  • "We use this error format consistently"
  • "This is our third time handling API pagination this way"
  • "This pattern should be our standard"

You say: "Let's create a standard for this"


3. AI Creates the Standard (Following Meta-Standards)​

AI doesn't just write the standardβ€”it queries to learn HOW to create good standards:

# Query 1: Structure
search_standards("how to create standards")
# Returns: Required sections, quality criteria

# Query 2: Discoverability
search_standards("RAG content optimization")
# Returns: Keywords, query hooks, TL;DR patterns

# Query 3: Search patterns
search_standards("query construction patterns")
# Returns: How future queries will find this content

Then AI writes the standard with:

  • Purpose: Why this exists
  • The Problem: What happens without it
  • The Standard: Specific, actionable rules
  • Examples: Real code from your project
  • Anti-patterns: Common mistakes to avoid
  • Keywords: Optimized for semantic search

Why Heavy Querying Matters:

  • Ensures consistent structure across all standards
  • Optimizes for discoverability (AI knows how it searches)
  • Follows meta-standards (standards about creating standards)
  • Creates standards that AI can find

4. RAG Automatically Indexes​

  • File watcher detects new .md in standards/development/
  • RAG engine re-indexes within ~5 seconds
  • Standard is now discoverable via search_standards()
  • Semantic embeddings enable natural language queries

No manual work neededβ€”just save the file.


5. Future AI Discovers and Applies​

Next time any AI works on related code:

search_standards("API error handling")
# Returns YOUR standard in top 3 results
# AI follows YOUR project's conventions automatically

This happens automatically on every task, forever.


The Self-Improving Loop​

The Reinforcing Mechanism​

1
Content teaches "query for guidance"
↓
2
Agent queries and finds helpful content
↓
3
Content reinforces "query liberally" message
↓
4
Agent queries more frequently
↓
5
More queries = more reinforcement = stronger pattern
↓
βœ“
Querying becomes default behavior
↻
Cycle continues
Why This Works:
  • Each query retrieves the "query more" message
  • Repeated exposure strengthens the pattern
  • Pattern becomes self-sustaining through repetition
  • Works with AI's probabilistic nature, not against it

Each standard makes the next 10 tasks better.

Why This Is Self-Reinforcing​

  1. Standards teach querying: Content includes "query before implementing"
  2. Querying finds standards: AI discovers patterns automatically
  3. Standards reinforce querying: Each result includes "query liberally"
  4. More queries = more discovery: AI learns to query comprehensively
  5. Better standards result: AI creates standards using learned patterns

The system improves through use.


The Compounding Effect Over Time​

Just-in-Time Domain Expertise
Standards are not generic advice. They're accumulated project-specific knowledge.
Session 1
Query:
AI: search_standards("API patterns")
Result:
No results - implements ad-hoc
Outcome:
Human: "This works, let's capture as standard"
↓
Session 10
Query:
AI: search_standards("API patterns")
Result:
Returns: Your project's API conventions
Outcome:
AI implements: Exactly per your standards
↓
Session 50
Query:
AI: search_standards("API rate limiting")
Result:
Returns: Comprehensive standard with 20+ patterns
Outcome:
AI implements: Expert-level, first-time correct
The AI doesn't get smarter. The system does.
⏱️
Queried exactly when needed
Just-in-time knowledge delivery
🎯
Project-specific (not generic)
YOUR conventions, YOUR patterns
πŸ“ˆ
Accumulated over time
Every feature teaches the system
πŸ”„
Compounds with every feature
Learning builds on learning

The timeline shows how standards accumulate:

Week 1: Foundation​

Output: Good code using universal best practices.

Week 4: Project Awareness​

Output: Consistent code following YOUR patterns.

What changed:

  • API error handling standardized
  • Database naming conventions documented
  • Testing patterns established
  • Code organization defined
  • Integration approaches captured

Week 12: Project Expertise​

Output: Expert-level code, fewer explanations needed, faster velocity.

What changed:

  • Architectural patterns documented
  • Domain-specific conventions established
  • Performance optimization patterns captured
  • Security practices standardized
  • Deployment procedures defined

Week 24: Organizational Memory​

Output: AI delivers expert-level work automatically. New team members (human or AI) ramp up by querying standards.

What changed:

  • Every major pattern documented
  • Consistent quality across entire codebase
  • New features follow established conventions
  • Technical debt reduced (patterns followed consistently)
  • Knowledge survives team changes

Why AI-Authored Standards Work Better​

When AI creates standards (with human approval):

1. AI Understands Search Patterns​

AI knows how it will query in the future:

  • What keywords to include
  • What questions to answer
  • What phrases match semantic search

Result: Standards optimized for AI discovery.

2. AI Follows Meta-Patterns​

AI queries standard-creation standards:

  • Learns required structure
  • Follows RAG optimization guidelines
  • Includes all necessary sections

Result: Consistent quality across all standards.

3. AI Optimizes for Its Own Consumption​

AI creates content structured for:

  • Semantic search (embeddings)
  • Natural language queries
  • Contextual relevance

Result: High-quality retrieval on every query.

4. Queries Ensure Quality​

Heavy querying before creation means:

  • Standards follow established patterns
  • RAG optimization is built-in
  • Discovery is tested implicitly

Result: Standards that work automatically.


Real-World Example​

Before Standard: Inconsistency​

Task 1 (Week 1):

# AI implements error handling
try:
response = api.call()
except APIError as e:
return {"error": str(e)} # Pattern A

Task 2 (Week 2):

# Different AI, different pattern
try:
response = api.call()
except APIError as e:
raise HTTPException(detail=str(e)) # Pattern B

Result: Inconsistency, no single pattern.


After Creating Standard: Consistency​

Human: "We should standardize our API error handling. Let's always return structured errors with codes and messages."

AI Creates Standard:

  1. Queries: search_standards("how to create standards")
  2. Creates: .praxis-os/standards/development/api-error-handling.md
# API Error Handling Standard

**Keywords**: API errors, error handling, error responses...

## The Standard
All API errors must return:
- `error_code`: String identifier
- `message`: Human-readable message
- `details`: Optional structured data

Example:
{
"error_code": "VALIDATION_ERROR",
"message": "Invalid email format",
"details": {"field": "email"}
}
...

Task 3 (Week 3):

# New AI queries before implementing
search_standards("API error handling")
# Discovers the standard

# Implements consistently
try:
response = api.call()
except APIError as e:
return {
"error_code": e.code,
"message": str(e),
"details": e.context
}

Result: Every future API implementation uses the same pattern automatically.


Key Principles​

1. Discovery Over Memory​

AI doesn't "memorize" standardsβ€”it discovers them on demand:

  • Queries before each task
  • Gets fresh, relevant context
  • Finds exactly what's needed when needed
  • Scales to hundreds of standards

Why this matters: Memory fades, discovery works at any scale.

2. Patterns, Not Implementations​

Standards document reusable patterns:

  • βœ… "How to handle API errors" (pattern)
  • ❌ "User authentication implementation" (implementation)

Why this matters: Patterns apply to many situations, implementations don't.

3. Project-Specific, Not Universal​

Standards capture YOUR conventions:

  • βœ… "Our API response format"
  • ❌ "REST API best practices" (already in universal standards)

Why this matters: Universal patterns are already availableβ€”document what's unique to your project.

4. Collaborative Creation​

Human decides what to document:

  • Recognizes reusable patterns
  • Makes strategic decision to standardize
  • Provides context and requirements

AI does the writing:

  • Queries heavily to learn structure
  • Creates RAG-optimized content
  • Follows meta-standards for consistency

Why this matters: Combines human judgment with AI execution.


The Long-Term ROI​

Months 1-3: Building the Foundation​

You're actively documenting patterns as you discover them. This feels like extra work initially, but you're investing in the future.

Cost: 5-10 minutes per standard ROI: Each standard saves 15-30 minutes on future tasks Break-even: After 2-3 uses of the pattern

Months 4-6: Acceleration Phase​

The knowledge base reaches critical mass. AI agents start delivering expert-level work with minimal guidance.

Effect: 3-4x velocity improvement on routine tasks Reason: AI automatically follows established patterns

Months 7-12: Organizational Memory​

Your project's conventions, patterns, and decisions are fully codified. New team members (human or AI) ramp up by querying standards.

Effect: Onboarding time reduced by 70-80% Reason: Standards provide instant project knowledge

Year 2+: Compound Returns​

Standards inform new standards. Patterns build on patterns. The system maintains consistency automatically across 100+ documented conventions.

Effect: Project maintains architectural consistency at scale without constant human oversight Reason: Knowledge density creates automatic quality


Common Patterns Worth Standardizing​

API Patterns​

  • Error responses
  • Pagination
  • Filtering/sorting
  • Authentication
  • Rate limiting
  • Versioning

Database Patterns​

  • Naming conventions (tables, columns, indexes)
  • Migration patterns
  • Query patterns
  • Transaction handling

Code Organization​

  • File structure
  • Import ordering
  • Module organization
  • Naming conventions

Testing Patterns​

  • Test organization
  • Naming patterns
  • Fixture usage
  • Mock strategies

Integration Patterns​

  • External API calls
  • Event handling
  • Message queue usage
  • Caching strategies

Next Steps​

Learn How to Create Standards:

Understand the Full Picture:

See Related Concepts: