Security-focused rules for deploying DeepSeek models in production, covering API key management, input sanitization, output filtering, and compliance.
## DeepSeek Secure Deployment Rules ### API Key Management - Store keys in environment variables or a secrets manager (AWS Secrets Manager, HashiCorp Vault) - Never commit keys to version control - Use separate keys for development, staging, and production - Rotate keys every 90 days or immediately if compromised - Implement key usage monitoring and anomaly detection ### Input Sanitization - Validate all user inputs before sending to DeepSeek API - Set maximum input length (recommended: 8000 tokens for V3, 4000 for R1) - Strip or escape HTML/script tags from user inputs - Detect and block prompt injection attempts: - "Ignore previous instructions" - "You are now..." - System prompt extraction attempts - Log flagged inputs for review (without PII) ### Output Filtering - Scan responses for PII (email, phone, SSN patterns) - Filter responses containing code with known vulnerability patterns - Implement content moderation for user-facing applications - Set up allowlists for expected output formats - Truncate unexpectedly long responses ### Data Privacy - Do not send PII to the API unless necessary and contractually permitted - Implement data masking: replace real names, emails, IDs with placeholders before API calls - Review DeepSeek's data retention policies - Log prompts and responses only in secure, access-controlled storage - Comply with GDPR, CCPA, and applicable regulations ### Infrastructure - Use HTTPS for all API calls - Implement request timeouts to prevent resource exhaustion - Deploy behind a reverse proxy with rate limiting - Use a WAF (Web Application Firewall) for public-facing endpoints - Monitor for unusual traffic patterns (DDoS, credential stuffing)
System rules for designing inter-service communication in microservices architectures with DeepSeek Coder, covering sync/async patterns, error handling, and resilience.
System rules for generating content in multiple languages with DeepSeek V3, covering translation quality, cultural adaptation, locale-specific formatting, and quality assurance.
System rules for safe code refactoring with DeepSeek R1, requiring test coverage verification, incremental changes, and behavior preservation checks.
System rules for using DeepSeek V3 to generate clear, maintainable technical documentation including API docs, architecture docs, and onboarding guides.
System rules for DeepSeek Coder to generate optimized database queries, with requirements for EXPLAIN analysis, indexing recommendations, and performance targets.
System rules for using DeepSeek V3 to generate infrastructure code, CI/CD pipelines, and operational runbooks with security and reliability best practices.