Automated privacy compliance for AI-assisted coding
By MΓ©tricas Boss - A comunidade brasileira de Analytics & Privacy
AI assistants like Claude, Copilot, and ChatGPT are transforming how we code. But they don't know LGPD or GDPR.
Common scenario:
- Developer asks Claude: "Add user tracking to this page"
- Claude generates code that collects CPF, email, phone
- Developer commits without reviewing
- Violation goes to production
- Fine: up to R$ 50 million
OTTO solves this.
It sits between the AI and your commits, catching privacy violations before they become fines.
OTTO automatically validates AI-generated code against LGPD and GDPR, blocking violations before they reach production.
Why you need this:
- AI assistants generate code fast, but don't validate compliance
- Developers trust AI output without reviewing privacy implications
- Manual code review is slow and misses subtle violations
- LGPD/GDPR fines start at R$ 50M / β¬20M per violation
Supported Regulations:
- π§π· LGPD (Lei 13.709/18) - Brazil
- πͺπΊ GDPR (EU 2016/679) - Europe
Developers using AI assistants:
- Claude Code, GitHub Copilot, ChatGPT, Cursor, etc.
- Writing code fast without privacy expertise
- Need compliance without slowing down
Teams shipping to Brazil/Europe:
- Startups moving fast
- Companies handling user data
- Anyone who can't afford a R$ 50M mistake
git clone https://github.com/metricasboss/otto.git
cd otto
./install.shDefault: Installs LGPD + GDPR for all detected editors.
Options:
./install.sh lgpd # Brazil only
./install.sh gdpr # Europe only
./install.sh --no-hooks # Skip automatic protectionSupported editors:
- Claude Code (with automatic hooks)
- Cursor (manual
/ottoonly) - OpenCode (manual
/ottoonly) - Codex (manual
/ottoonly) - Antigravity (manual
/ottoonly)
Note: Automatic protection (hooks) only works on Claude Code. Other editors require manual invocation with /otto.
- CPF/RG/CNPJ hardcoded in code
- Personal data in logs (console.log, logger)
- Tracking/analytics without consent verification
- SQL queries violating data minimization (SELECT *)
- Passwords in plaintext
- API keys and secrets exposed
- Cookies set without consent
- Data sharing with third parties without authorization
- SQL injection vulnerabilities
- SSN/National ID numbers exposed
- Personal data in logs
- Tracking without consent
- Queries violating data minimization
- Unencrypted sensitive data
- Health/biometric data (special categories)
- localStorage misuse for sensitive data
- External data transfers without legal basis
OTTO works with multiple AI coding editors:
Claude Code (Full Support):
- Automatic invocation when Claude detects personal data
- Real-time feedback during coding
- Automatic hooks: Validates before edits/commits
- Fix suggestions with compliant code
Other Editors (Cursor, OpenCode, Codex, Antigravity):
- Manual invocation only:
/ottoor/otto scan <path> - Same violation detection patterns
- No automatic hooks (editor limitation)
- Useful for manual code review
When hooks are enabled on Claude Code:
- Before edits: Blocks privacy violations before they're saved
- Before commits: Ensures clean commits
- CI/CD ready: Can integrate into your build pipeline
Once installed with hooks enabled, OTTO works automatically:
// You write code with privacy issues
console.log('User:', user); // Exposes PII
// OTTO blocks and suggests fix:
// Use: console.log('User ID:', user.id)Invoke OTTO directly in Claude Code:
# Analyze current context
/otto
# Scan specific directory
/otto scan src/
# Scan before commit
/otto scan .Run the scanner directly on files:
python3 ~/.claude/skills/otto/scripts/scan_privacy.py myfile.jsOTTO - LGPD Privacy Analysis
VIOLATIONS FOUND: 3
File: src/auth/login.js
1. CPF Exposure
Line: 15
Severity: CRITICAL
Issue:
CPF brasileiro exposto no cΓ³digo
Legal basis violated:
LGPD Art. 46 (Dados SensΓveis)
Fine risk:
AtΓ© R$ 50 milhΓ΅es
SUGGESTED FIX:
Remove hardcoded CPF. Retrieve from encrypted database
or use environment variable for tests.
[... more violations ...]
SUMMARY:
β’ 3 critical violations
β’ Risk: up to R$ 150 million
NEXT STEPS:
1. Fix critical violations immediately
2. Implement consent verification system
3. Add privacy tests to CI/CD
4. Document legal basis for data processing
OTTO protected your users today.
- Up to R$ 50 million per violation (Art. 52)
- Public disclosure of violations
- Data blocking/deletion orders
- Up to β¬20M or 4% of annual global turnover (whichever is higher)
- Applies per violation
- Cumulative fines for multiple violations
Example: 3 critical violations = potential R$ 150M (LGPD) or β¬60M (GDPR)
// Developer prompt: "Add analytics tracking for user login"
// AI generates:
const user = await getUser(userId);
console.log('User logged in:', user); // β Logs PII
analytics.track('login', {
email: user.email, // β No consent check
cpf: user.cpf, // β Sensitive data
location: user.address // β Unnecessary data
});What happens:
- β AI doesn't know LGPD requires consent
- β AI doesn't know CPF is sensitive data
- β AI doesn't know about data minimization
- π° Fine: R$ 150 million (3 violations)
OTTO - LGPD Analysis
β 3 VIOLATIONS FOUND
1. Personal data in logs (Line 3)
LGPD Art. 46 - Fine: R$ 50M
Fix: console.log('User ID:', user.id)
2. Tracking without consent (Line 4)
LGPD Art. 7ΒΊ - Fine: R$ 50M
Fix: if (user.hasConsent('analytics')) { ... }
3. Unnecessary data collection (Line 6)
LGPD Art. 6ΒΊ III - Fine: R$ 50M
Fix: Remove 'location' field
// OTTO auto-corrected:
const user = await getUser(userId);
console.log('User ID:', user.id); // β
No PII
if (user.hasConsent('analytics')) { // β
Consent check
analytics.track('login', {
userId: hash(user.id) // β
Anonymized, no sensitive data
});
}Result: β LGPD compliant, zero fines
otto/
βββ install.sh # Interactive installer
βββ README.md # This file
βββ QUICKSTART.md # 2-minute setup guide
βββ LICENSE # MIT License
β
βββ skills/
β βββ lgpd/ # Brazilian regulation
β β βββ SKILL.md # LGPD skill definition
β β βββ patterns.json # LGPD violation patterns
β β
β βββ gdpr/ # European regulation
β βββ SKILL.md # GDPR skill definition
β βββ patterns.json # GDPR violation patterns
β
βββ scripts/
β βββ scan_privacy.py # Python scanner engine
β
βββ examples/
βββ unsafe_code.js # Code with violations
βββ safe_code.js # Compliant code
OTTO itself respects your privacy:
- No data collection: Runs entirely locally
- No network calls: Patterns are local JSON files
- Open source: Audit the code yourself
- No telemetry: Your code never leaves your machine
Contributions are welcome! Especially:
- New violation patterns
- Support for other regulations (CCPA, PIPEDA, etc.)
- Bug fixes and improvements
- Documentation updates
- Test cases
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-pattern - Add your changes
- Test thoroughly
- Submit a pull request
Edit skills/lgpd/patterns.json or skills/gdpr/patterns.json:
{
"pattern_name": {
"regex": "your-regex-here",
"severity": "critical|high|medium|low",
"article": "Regulation Article",
"message": "Description of the violation",
"fix": "How to fix it",
"fine": "Penalty amount"
}
}- README.md - Complete guide (this file)
- QUICKSTART.md - 2-minute setup
- DEPLOY.md - Deployment instructions
- demo/ - Demo script and GIF recording instructions
Claude Code:
- Check installation:
ls -la ~/.claude/skills/otto/ - Restart Claude Code
- Run
/helpto see if/ottois listed
Cursor:
- Check installation:
ls -la ~/.cursor/skills/otto/ - Restart Cursor
- Type
/ottoto invoke manually
Other editors: Check respective skill directories
- Check settings:
cat ~/.claude/settings.json - Verify Python is installed:
python3 --version - Make scanner executable:
chmod +x ~/.claude/skills/otto/scripts/scan_privacy.py - Note: Hooks only work on Claude Code, not other editors
OTTO uses regex patterns and may flag legitimate code. You can:
- Add context in comments explaining why code is safe
- Adjust patterns in
~/.claude/skills/otto/scripts/patterns.json - Disable specific patterns by removing them from JSON
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Community: MΓ©tricas Boss
MIT License - See LICENSE file for details.
Built by the MΓ©tricas Boss community for developers who value privacy compliance.