cohere-security-basics
Apply Cohere security best practices for API key management and access control. Use when securing API keys, implementing key rotation, or auditing Cohere security configuration. Trigger with phrases like "cohere security", "cohere secrets", "secure cohere", "cohere API key security", "cohere key rotation".
What this skill does
# Cohere Security Basics
## Overview
Security best practices for Cohere API keys, request validation, and data protection. Cohere uses bearer token auth with trial and production key tiers.
## Prerequisites
- Cohere account at [dashboard.cohere.com](https://dashboard.cohere.com)
- Understanding of environment variables
- Secret management solution for production
## Instructions
### Step 1: API Key Management
```bash
# NEVER hardcode keys — use environment variables
export CO_API_KEY="your-key-here"
# .env file (MUST be git-ignored)
CO_API_KEY=your-key-here
# .gitignore (mandatory entries)
.env
.env.local
.env.*.local
```
**Key types:**
- **Trial keys** — free, rate-limited, for development only
- **Production keys** — metered billing, for live applications
### Step 2: Runtime Validation
```typescript
import { CohereClientV2 } from 'cohere-ai';
function createSecureClient(): CohereClientV2 {
const apiKey = process.env.CO_API_KEY;
if (!apiKey) {
throw new Error('CO_API_KEY is required. Set it as an environment variable.');
}
// Basic key format check
if (apiKey.length < 20) {
throw new Error('CO_API_KEY appears malformed. Check dashboard.cohere.com.');
}
return new CohereClientV2({ token: apiKey });
}
```
### Step 3: Key Rotation Procedure
```bash
# 1. Generate new key in Cohere dashboard
# → dashboard.cohere.com → API Keys → Create new key
# 2. Deploy new key (keep old key active)
# Vercel:
vercel env add CO_API_KEY production
# AWS:
aws secretsmanager update-secret --secret-id cohere/api-key --secret-string "new-key"
# GCP:
echo -n "new-key" | gcloud secrets versions add cohere-api-key --data-file=-
# 3. Verify new key works
curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer NEW_KEY" \
-H "Content-Type: application/json" \
https://api.cohere.com/v2/chat \
-d '{"model":"command-r7b-12-2024","messages":[{"role":"user","content":"test"}]}'
# Should return 200
# 4. Revoke old key in dashboard
# 5. Monitor for 401 errors after revocation
```
### Step 4: Request Data Protection
```typescript
// Scrub PII before sending to Cohere API
const PII_PATTERNS: [string, RegExp][] = [
['email', /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g],
['phone', /\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/g],
['ssn', /\b\d{3}-\d{2}-\d{4}\b/g],
];
function scrubPII(text: string): string {
let scrubbed = text;
for (const [type, regex] of PII_PATTERNS) {
scrubbed = scrubbed.replace(regex, `[REDACTED_${type.toUpperCase()}]`);
}
return scrubbed;
}
// Use before API calls when handling user data
async function safeCohereChat(userInput: string) {
const sanitized = scrubPII(userInput);
return cohere.chat({
model: 'command-a-03-2025',
messages: [{ role: 'user', content: sanitized }],
safetyMode: 'CONTEXTUAL', // CONTEXTUAL (default), STRICT, or OFF
});
}
```
### Step 5: Logging Safety
```typescript
import { CohereError } from 'cohere-ai';
function safeLog(message: string, data?: Record<string, unknown>) {
const sanitized = { ...data };
// Never log API keys
delete sanitized.apiKey;
delete sanitized.token;
delete sanitized.authorization;
// Truncate request/response bodies
if (typeof sanitized.body === 'string' && (sanitized.body as string).length > 500) {
sanitized.body = (sanitized.body as string).slice(0, 500) + '...[truncated]';
}
console.log(`[cohere] ${message}`, sanitized);
}
// Wrap error logging
function logCohereError(err: unknown) {
if (err instanceof CohereError) {
safeLog('API error', {
status: err.statusCode,
message: err.message,
// Do NOT log err.body — may contain sensitive request data
});
}
}
```
### Step 6: Safety Modes
Cohere's Chat API supports safety modes that control content filtering:
```typescript
// CONTEXTUAL (default): Adapts based on context
await cohere.chat({
model: 'command-a-03-2025',
messages: [{ role: 'user', content: prompt }],
safetyMode: 'CONTEXTUAL',
});
// STRICT: Maximum safety filtering
await cohere.chat({
model: 'command-a-03-2025',
messages: [{ role: 'user', content: prompt }],
safetyMode: 'STRICT',
});
// Note: safetyMode not configurable with tools or documents params
```
## Security Checklist
- [ ] `CO_API_KEY` stored in environment variables, never in code
- [ ] `.env` files listed in `.gitignore`
- [ ] Separate keys for development and production
- [ ] Key rotation scheduled (quarterly recommended)
- [ ] PII scrubbed from inputs sent to Cohere
- [ ] API keys excluded from all log output
- [ ] Production key has billing alerts configured
- [ ] Git pre-commit hook scans for leaked keys
## Git Pre-Commit Hook
```bash
#!/bin/bash
# .git/hooks/pre-commit — detect Cohere keys in staged files
if git diff --cached --diff-filter=ACM | grep -qiE 'CO_API_KEY|cohere.*key.*=.*[a-zA-Z0-9]{20}'; then
echo "ERROR: Possible Cohere API key in commit. Remove before committing."
exit 1
fi
```
## Error Handling
| Security Issue | Detection | Mitigation |
|----------------|-----------|------------|
| Key in git history | `git log -p \| grep CO_API_KEY` | Rotate key immediately |
| Key in logs | Log audit | Add log scrubbing |
| Key in error report | Error handler review | Sanitize error payloads |
| Excessive token spend | Billing dashboard | Set budget alerts |
## Resources
- [Cohere API Keys Dashboard](https://dashboard.cohere.com/api-keys)
- [Cohere Safety Modes](https://docs.cohere.com/docs/safety-modes)
- [Cohere Rate Limits](https://docs.cohere.com/docs/rate-limits)
## Next Steps
For production deployment, see `cohere-prod-checklist`.
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.