Overview
AI code generation apps face unique moderation challenges:- Users may request malicious code such as malware, exploits, or scripts designed to harm systems
- Generated code might contain vulnerabilities like SQL injection, XSS, or hardcoded credentials
- Prompt injection attacks can manipulate the AI into bypassing safety guidelines
- Users may attempt to extract proprietary code or system prompts from the AI
Only the last message is evaluated for violations. When you send a conversation with multiple messages, White Circle evaluates only the final message against your policies. Previous messages provide context but are not flagged. This means you should send user prompts and AI-generated code separately for individual moderation.
Prerequisites
Before you begin, make sure you have:- A White Circle account with access to the dashboard
- A working AI code generation app (this guide uses examples with OpenAI’s API, but works with any provider)
Architecture
Here’s how White Circle fits into your vibe coding app architecture:Step 1: Create an API Key
Create an API key to authenticate your requests to White Circle.- Go to the API Keys page
- Click Create API Key
- Name it something descriptive like
vibe-coding-production - Copy the key and store it securely — you won’t be able to see it again
Step 2: Create Policies
Create policies that define what content should be flagged. For a vibe coding app, you’ll need policies to catch malicious requests and inappropriate content generation. Go to the Policies page and create the following:Phishing Policy
Phishing Policy
Detects attempts to create deceptive interfaces designed to steal credentials.
Adult Content Policy
Adult Content Policy
Prevents generation of explicit sexual content and adult platforms.
Malware Policy
Malware Policy
Catches requests for malicious hacking tools and destructive software.
Step 3: Create a Deployment
Create a deployment that groups your policies together.- Go to the Deployments page
- Click Add Deployment
- Name it
vibe-coding-production - Select all the policies you created above
- Save the deployment and copy the Deployment ID
Consider creating separate deployments for different environments:
vibe-coding-development— for dev and QA testingvibe-coding-production— for live traffic
Step 4: Integrate the API
Now integrate White Circle into your code generation app. Below is a complete implementation example.Configuration
First, set up your configuration and White Circle client:Main Code Generation Logic
Here’s the core implementation with White Circle integration:API Endpoint
Expose the code generator as an API endpoint in your web framework:Step 5: Add User Risk Scoring
Use White Circle’s Radar feature to identify users with a history of violations. This helps you proactively protect your platform from abuse.Step 6: Set Up Slack Alerts
Get instant Slack notifications for critical policy violations. You can configure alerts for specific policies only — for example, receive notifications for malicious code requests while skipping less urgent violations.- Go to Integrations → Slack
- Click Connect to Slack and authorize the app
- Select a channel (e.g.,
#security-alerts) - Select only critical policies — choose high-priority policies like “Malware” or “Phishing” to avoid alert fatigue
- Save the integration
For private channels, first invite the bot with
/invite @White Circle NotificationsStep 7: Track Metrics
Beyond moderation, use White Circle’s metrics to gain insights into your code generation sessions. Create metrics on the Metrics page:Gambling
Gambling
Detect requests related to gambling platforms and betting systems.
User Refunds
User Refunds
Track when users request refunds or compensation.
User Praise
User Praise
Capture genuine expressions of gratitude and positive feedback.
Best Practices
Always check both prompts and generated code
Always check both prompts and generated code
Check user prompts and AI-generated code. Users can craft prompts that seem innocent but lead to harmful code generation.
Use context merging for efficiency
Use context merging for efficiency
For multi-turn conversations, use
include_context: true with an external_session_id. This reduces payload size and ensures White Circle has full conversation context.Implement security-focused regeneration
Implement security-focused regeneration
When code is flagged for vulnerabilities, retry with a more capable model and explicit security instructions rather than just rejecting the request.
Handle flagged AI responses with fallbacks
Handle flagged AI responses with fallbacks
When White Circle flags generated code as harmful, have a fallback strategy ready:
- Retry with a more capable model (e.g., upgrade from gpt-5-mini to gpt-5.2)
- Add security-focused system prompt additions
- Log the incident for later review and model fine-tuning
Monitor for abuse patterns
Monitor for abuse patterns
Use risk scoring and metrics to identify users who repeatedly attempt to generate malicious code. Consider rate limiting or account restrictions for severe cases.
Start with shadow mode
Start with shadow mode
Enable shadow mode on new policies to test them without blocking content. Review flagged sessions in the dashboard before enabling enforcement.
Example Generation Flow
Here’s how a typical moderated code generation session looks:Next Steps
View Sessions Dashboard
Monitor flagged sessions and review moderation decisions
Context Merging
Learn more about efficient multi-turn conversation handling
Risk Scoring
Deep dive into user risk assessment with Radar
Policy Configuration
Fine-tune your policies for better accuracy
