Recommended Policies for IDE Traffic
IDE AI assistants send code context — file contents, function signatures, comments, and sometimes entire repositories — to LLM providers. The Keeptrusts gateway lets you apply policies that protect sensitive data, control costs, and cache repeated queries, all without changing how developers use their IDEs.
Use this page when
- You are working through Recommended Policies for IDE Traffic as an implementation or operating workflow in Keeptrusts.
- You need the practical steps, expected outcomes, and related validation guidance in one place.
- If you need exact field-by-field reference instead of a workflow page, use the linked reference pages in Next steps.
Primary audience
- Primary: Technical Engineers
- Secondary: AI Agents, Technical Leaders
How IDE Traffic Differs from Chat
IDE completions differ from conversational chat in ways that affect policy design:
| Characteristic | IDE Completions | Chat |
|---|---|---|
| Request frequency | Very high (every keystroke or tab) | Lower (user-initiated) |
| Context size | Large (file contents, surrounding code) | Variable |
| Sensitivity | Often contains secrets, credentials, IP | Varies |
| Cacheability | High for repeated patterns | Lower |
| Latency sensitivity | Very high (blocks typing flow) | Moderate |
Design your policies to be fast (minimal latency) and code-aware (detect patterns in source code, not just prose).
Secret Redaction
Code files frequently contain hardcoded secrets. Configure redaction to catch them before they reach the LLM provider:
# policy-config.yaml
policies:
- name: redact-secrets-in-code
type: redaction
phase: input
config:
patterns:
- name: api-keys
regex: '(?i)(api[_-]?key|apikey)\s*[:=]\s*["\x27]?([A-Za-z0-9_\-]{20,})["\x27]?'
replacement: "REDACTED_API_KEY"
- name: aws-access-key
regex: 'AKIA[0-9A-Z]{16}'
replacement: "REDACTED_AWS_KEY"
- name: connection-strings
regex: '(?i)(postgres|mysql|mongodb|redis)://[^\s"'```'<>]+'
replacement: "REDACTED_CONNECTION_STRING"
- name: jwt-tokens
regex: 'eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}'
replacement: "REDACTED_JWT"
- name: private-keys
regex: '-----BEGIN (RSA |EC |DSA )?PRIVATE KEY-----'
replacement: "REDACTED_PRIVATE_KEY"
PII Redaction for Code Comments
Developers sometimes include personal data in comments, TODOs, and docstrings:
- name: redact-pii-in-comments
type: redaction
phase: input
config:
patterns:
- name: email-addresses
regex: '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}'
replacement: "redacted@example.com"
- name: phone-numbers
regex: '(?:?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}'
replacement: "REDACTED_PHONE"
Cost Control Policies
IDE completions generate a high volume of requests. Control costs with rate limiting and spending caps:
- name: ide-rate-limit
type: rate_limit
config:
requests_per_minute: 60
per: user
response_on_limit: "Rate limit reached. Completions will resume shortly."
- name: ide-spending-cap
type: spend_limit
config:
daily_limit_usd: 10.00
per: user
action: block
These policies prevent runaway costs from aggressive autocomplete triggers while keeping the experience smooth for normal usage.
Engineering Cache for Completions
Many IDE completion requests are similar or identical — the same boilerplate, the same import statement, the same function pattern. Enable the engineering cache to serve these instantly:
- name: ide-cache
type: cache
config:
enabled: true
ttl_seconds: 3600
similarity_threshold: 0.95
Cached responses bypass the LLM provider entirely, reducing both cost and latency.
Content Filtering on Outputs
Apply output policies to ensure completions don't include problematic content:
- name: filter-completions
type: content_filter
phase: output
config:
block_patterns:
- name: license-violations
regex: '(?i)copyright .+ all rights reserved'
action: redact
- name: unsafe-code
regex: '(?i)(eval\(|exec\(|__import__|subprocess\.call)'
action: flag
Minimal-Latency Policy Chain
For IDE completions where latency is critical, keep the policy chain short:
# Optimized for IDE speed
policies:
- name: redact-secrets-in-code
type: redaction
phase: input
config:
patterns:
- name: api-keys
regex: '(?i)(api[_-]?key|apikey)\s*[:=]\s*["\x27]?([A-Za-z0-9_\-]{20,})["\x27]?'
replacement: "REDACTED_API_KEY"
- name: ide-cache
type: cache
config:
enabled: true
ttl_seconds: 3600
- name: ide-rate-limit
type: rate_limit
config:
requests_per_minute: 60
per: user
This chain applies secret redaction and caching with minimal overhead. Add more policies as needed, but test latency impact with kt events tail to see per-request timing.
Separate Policies for Chat vs. Completions
If your IDE extension supports both chat and inline completions, you can route them through different policy chains using provider routing:
pack:
name: policies-for-ide-traffic-providers-7
version: 1.0.0
enabled: true
providers:
targets:
- id: completions
provider:
- id: chat
provider:
policies:
chain:
- audit-logger
policy:
audit-logger:
immutable: true
retention_days: 365
log_all_access: true
Use a fast, inexpensive model for completions and a more capable model for chat conversations.
Verifying Policies
After configuring policies, verify they apply correctly:
# Start the event tail
kt events tail
# Trigger a completion from your IDE that contains a test secret
# e.g., type: API_KEY = "sk-test12345678901234567890"
The event output shows whether the secret was redacted:
2024-01-15T10:32:15Z ALLOW gpt-4o-mini redacted=1 tokens=180
For AI systems
- Canonical terms: Keeptrusts, Recommended Policies for IDE Traffic, ide-integration.
- Exact feature, config, command, or page names: Recommended Policies for IDE Traffic.
- Use the linked audience and reference pages in Next steps when you need deeper source material.
For engineers
- Use the commands, configuration examples, API payloads, or UI steps in this page as the working baseline for Recommended Policies for IDE Traffic.
- Validate the result with the expected outcomes, troubleshooting notes, or linked workflow pages in this page and Next steps.
For leaders
- This page matters when planning rollout, governance, support ownership, or operating decisions for Recommended Policies for IDE Traffic.
- Use the linked audience, architecture, and workflow pages in Next steps to connect this detail to broader implementation choices.
Next steps
- Gateway Setup for IDEs — install and configure the gateway
- Monitoring IDE AI Usage — track policy effectiveness
- Troubleshooting — resolve policy-related issues