A systematic approach to maintaining consistent, accurate documentation across all AI tools and contexts.
The Guardrails-AI project follows a single source of truth approach to documentation. This means all standards, guidelines, and requirements are defined once in canonical documents, then derived and optimized for specific AI tools.
CONTEXT.md
Master standards document
AGENTS.md
Workflow instructions
CONTRIBUTING.md
Contribution guidelines
.cursor/rules/*.mdc
Derived from CONTEXT.md
CLAUDE.md
Derived from CONTEXT.md
.github/copilot-instructions.md
Derived from CONTEXT.md
.aider/.aider.conf.yml
References CONTEXT.md
To eliminate manual effort and prevent configuration drift, AI Guardrails includes an automated standards synchronization system with preprocessing and tool-specific optimization.
CONTEXT.md โ Parser โ Preprocessor โ AI Enhancement โ Tool Configs
(source) (extract) (transform) (optional) (outputs)
โโโ Cursor (.mdc, imperative)
โโโ Claude (.md, conversational)
โโโ Copilot (.md, concise)
โโโ Aider (.yml, structured)
โโโ Continue.dev (.yaml, rules)
Step 1: Update CONTEXT.md (human edits canonical source)
vim CONTEXT.md
# Add new rule: "Never use eval() in Python"
Step 2: Run Sync Script (automation handles the rest)
./scripts/sync-standards.sh
# Automatically:
# - Parses CONTEXT.md
# - Transforms for each tool's style
# - Generates optimized configs
# - Validates consistency
Step 3: Review & Commit (human verifies changes)
git diff # Review changes
git commit -am "Add rule: no eval() in Python"
The same rule transforms differently for each AI tool's optimal style:
## Never Use eval()
Python code MUST NOT use eval().
This is a security vulnerability.
โ WRONG:
result = eval(user_input)
### Never Use eval()
You must never use eval() in Python.
Why this matters:
eval() can execute arbitrary code
and is a major security risk.
## No eval()
Never use eval() - security risk.
# โ Bad: eval(user_input)
# โ
Good: ast.literal_eval()
โ The synchronization system is IMPLEMENTED and ready for production use!
๐ก
Try the POC:
python3 scripts/sync-standards-poc.py --dry-run
These are the master documents that define all project standards:
Purpose: Defines all coding standards, security requirements, and best practices
Authority: Highest - overrides all other documentation
Update frequency: Only when standards change project-wide
Purpose: Describes how to work on the project (workflow, processes, commands)
Authority: High - complements CONTEXT.md
Update frequency: When workflow or tooling changes
Purpose: Guides human and AI contributors on how to contribute
Authority: High - applies to all contributors
Update frequency: When contribution process changes
These files are derived from the canonical documents and optimized for specific AI tools:
.cursor/rules/*.mdc - Cursor IDE rules (scoped, prioritized)CLAUDE.md - Claude Desktop instructions (conversational).claudeprompt - Claude Projects (concise).github/copilot-instructions.md - GitHub Copilot (example-heavy).aider/.aider.conf.yml - Aider config (YAML, auto-reads CONTEXT.md).continue/config.yaml - Continue.dev (rules + prompts)# Security Standards
## Never Commit Secrets
API keys, tokens, and passwords must NEVER be committed to the repository.
### Correct Approach
```python
import os
# Load from environment
api_key = os.environ.get("API_KEY")
if not api_key:
raise ValueError("API_KEY not set")
```
### Incorrect Approach
```python
# โ NEVER do this!
api_key = "sk-1234567890abcdef"
```
## File Requirements
1. All code must pass pre-commit hooks
2. Type hints required for Python functions
3. Docstrings required for public APIs
markdownlint.pymarkdown.json.yaml (NOT .yml)yamllintWith the automated synchronization system:
# Edit the canonical document
vim CONTEXT.md
# Add your new rule or update existing standard
# Automatic preprocessing and tool-specific transformation
./scripts/sync-standards.sh
# With AI enhancement (optional)
./scripts/sync-standards.sh --with-ai
git diff # Review all changes
git commit -am "Add rule: [rule name]"
Time savings: 15-30 minutes โ 2 minutes per update (70%+ reduction)
Until automation is implemented, follow the manual process:
# Edit the canonical document
vim CONTEXT.md
# Commit with clear message
git add CONTEXT.md
git commit -m "docs: update Python type hints standard"
# Update Cursor rules
vim .cursor/rules/004_python_standards.mdc
# Update Claude instructions
vim CLAUDE.md
# Update Copilot instructions
vim .github/copilot-instructions.md
# Commit all changes together
git add .cursor/ CLAUDE.md .github/
git commit -m "docs: propagate Python standards to all AI tools"
Manual time: 15-30 minutes per update
Documentation follows semantic versioning principles:
# Markdown linting
pre-commit run markdownlint --files CONTEXT.md
# YAML linting
pre-commit run yamllint --files .cursor/rules/001_workspace.mdc
Every standard must include both correct โ and incorrect โ examples
Use imperative mood: "Use environment variables" not "You should use environment variables"
Derived documents must reference their canonical source:
This document is derived from CONTEXT.md.
For the canonical version, see: CONTEXT.md
All code examples must:
Link related documentation:
## Security Standards
See also:
- [Pre-commit Hooks](./pre-commit-hooks.html) - Automated secret detection
- [CI/CD](./ci-cd.html) - Security scanning in pipelines
- [CONTEXT.md](https://github.com/christopherpaquin/Guardrails-AI/blob/main/CONTEXT.md) - Full security requirements
All documentation changes are validated by pre-commit hooks:
markdownlint - Markdown style and syntaxtrailing-whitespace - Remove trailing spacesend-of-file-fixer - Ensure newline at endcheck-yaml - Validate YAML syntaxmixed-line-ending - Fix CRLF/LF issuesHelp improve the AI Guardrails documentation for everyone.
Read Contributing Guide