GR

groq-security-basics

Covers security hardening for Groq API integrations, including key rotation, environment variable management, and proxy patterns.

Install

mkdir -p .claude/skills/groq-security-basics && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/6606" && unzip -o skill.zip -d .claude/skills/groq-security-basics && rm skill.zip

Installs to .claude/skills/groq-security-basics

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Apply Groq security best practices for API key management and data protection.
78 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Store Groq API keys in environment variables or secret managers
  • Implement a zero-downtime key rotation procedure
  • Install a pre-commit hook to prevent `gsk_` key leaks
  • Proxy Groq API calls through a backend to protect keys
  • Sanitize user input and harden system prompts against injection
  • Log every completion with token counts, latency, and status

How it works

The skill guides through six steps to secure Groq API usage, including key storage, rotation, leak prevention, server-side proxying, prompt injection defense, and audit logging.

Inputs & outputs

You give it
Groq API key, Groq API calls, user input for prompts
You get back
Hardened Groq integration, git-ignored API key, pre-commit hook, audit log entries

When to use groq-security-basics

  • Hardening API key storage in production
  • Implementing server-side proxy patterns for API calls
  • Auditing repository for hardcoded secrets
  • Configuring prompt-injection defense layers

About this skill

Groq Security Basics

Overview

Security practices for Groq API keys and data flowing through Groq's inference API. Groq uses a single API key type (gsk_ prefix) with full access -- there are no scoped tokens -- so key management and rotation are critical.

This skill walks through six hardening steps end to end. The essentials live here; deep code and full command sequences are extracted into references/ for progressive disclosure:

Prerequisites

  • Groq account at console.groq.com
  • Understanding of environment variable management
  • Secret management solution for production (Vault, AWS Secrets Manager, etc.)

Key Security Facts

  • Groq API keys start with gsk_ and grant full API access
  • There are no read-only or scoped keys -- every key can call every endpoint
  • Keys are created at console.groq.com/keys and cannot be viewed after creation
  • Rate limits are per-organization, not per-key
  • Groq does not store prompt data for training (see privacy policy)

Instructions

Work through the six steps in order. Each summary below is enough to act on; drill into the linked reference for the full code.

Step 1: Secure Key Storage by Environment

Keep the key out of source. Use a .env.local (git-ignored) for development and a platform secret manager (Vercel / AWS / GCP / GitHub Actions) for production. Use Write to create the .env.local and .gitignore entries:

echo "GROQ_API_KEY=gsk_dev_key_here" > .env.local
echo -e ".env\n.env.local\n.env.*.local" >> .gitignore

Full per-platform commands: references/examples.md Example 1.

Step 2: Key Rotation Procedure

Both keys work simultaneously, so rotation is zero-downtime: create a date-named key, deploy it, verify with a 200 from /v1/models, monitor 24h, then delete the old key. Full sequence: references/examples.md Example 2.

Step 3: Git Leak Prevention

Install a pre-commit hook that blocks any staged gsk_ key. Use Read to confirm .gitignore excludes the .env files, then use Grep to sweep the existing tree and history for keys already committed:

grep -rnE "gsk_[a-zA-Z0-9]{20,}" . --exclude-dir=.git

Hook + history-scan commands: references/examples.md Examples 3-4.

Step 4: Server-Side Key Usage Pattern

Never expose the key to client code. Proxy inference through your backend so the key stays server-side, and validate/limit user input before calling Groq. Full Next.js route handler: references/implementation.md § Server-Side Key Usage Pattern.

Step 5: Prompt Injection Defense

Sanitize user input to strip override phrases (ignore previous instructions, you are now, system:) and pair it with a hardened system prompt that refuses role changes. Full code: references/implementation.md § Prompt Injection Defense.

Step 6: Audit Logging

Log every completion with token counts, latency, and status so abuse and cost spikes trace back to a user. Full auditedCompletion implementation: references/implementation.md § Audit Logging.

Output

Applying this skill produces a hardened Groq integration:

  • A git-ignored .env.local (dev) and secret-manager entry (prod) — no key in source
  • A .git/hooks/pre-commit hook that exits non-zero on any staged gsk_ key
  • A documented, tested rotation runbook with date-named keys
  • A backend proxy route so the key never reaches the client
  • Input sanitization + a hardened system prompt guarding against injection
  • Structured audit log entries (GroqAuditEntry) on every completion
  • A completed Security Checklist (below) with all items verified

Error Handling

  • 401 Unauthorized from /v1/models — the rotated key is wrong or not yet propagated to the secret manager. Re-check the Authorization: Bearer value before deleting the old key.
  • Pre-commit hook not firing — confirm the file is executable (chmod +x .git/hooks/pre-commit); hooks are not copied by git clone, so re-install per checkout.
  • Grep finds a key already in history — rotate the key immediately (Step 2); scrubbing history alone is not enough because the key was exposed.
  • Client-side GROQ_API_KEY reference — any bundler that inlines the key (e.g. a NEXT_PUBLIC_ prefix) leaks it; move the call server-side (Step 4).
  • Rate limits hit unexpectedly — limits are per-organization, not per-key, so a leaked key shares your quota; a sudden 429 spike can indicate abuse.

Examples

Lean summaries are in Instructions; full copy-ready code lives in the references:

Security Checklist

  • API key in environment variable, not source code
  • .env files in .gitignore
  • Pre-commit hook for key leak detection
  • Separate keys for dev/staging/prod (different Groq orgs)
  • Key rotation documented and tested
  • Groq calls proxied through backend (never client-side)
  • User input sanitized before sending to Groq
  • System prompt hardened against injection
  • Audit logging on all completions
  • Spending limits set in Groq Console

Resources

Next Steps

For production deployment, work through the groq-prod-checklist skill, which covers deployment gates, monitoring, and spend controls beyond this security baseline.

When not to use it

  • When the Groq API key is exposed to client-side code
  • When a `gsk_` key is already committed to version control history

Prerequisites

Groq account at console.groq.comUnderstanding of environment variable managementSecret management solution for production

Limitations

  • Groq API keys grant full API access and cannot be scoped
  • Rate limits are per-organization, not per-key
  • Groq does not store prompt data for training

How it compares

This skill provides specific Groq-focused security steps, unlike generic security advice that may not address Groq's single API key type with full access.

Compared to similar skills

groq-security-basics side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
groq-security-basics (this skill)127dReviewIntermediate
security-header-generator59moCautionIntermediate
fix-dependabot-alerts186moReviewIntermediate
backend-security-coder244moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

security-header-generator

Dexploarer

Generates security HTTP headers (CSP, HSTS, CORS, etc.) for web applications to prevent common attacks. Use when user asks to "add security headers", "setup CSP", "configure CORS", "secure headers", or "HSTS setup".

599

fix-dependabot-alerts

microsoft

Fix Dependabot security alerts by updating vulnerable npm dependencies. Use when the user mentions "dependabot", "security alerts", "vulnerability", "CVE", or wants to update packages with security issues.

1872

backend-security-coder

sickn33

Expert in secure backend coding practices specializing in input validation, authentication, and API security. Use PROACTIVELY for backend security implementations or security code reviews.

2446

security-best-practices

openai

Perform language and framework specific security best-practice reviews and suggest improvements. Trigger only when the user explicitly requests security best practices guidance, a security review/report, or secure-by-default coding help. Trigger only for supported languages (python, javascript/typescript, go). Do not trigger for general code review, debugging, or non-security tasks.

732

dependency-auditor

alirezarezvani

Check dependencies for known vulnerabilities using npm audit, pip-audit, etc. Use when package.json or requirements.txt changes, or before deployments. Alerts on vulnerable dependencies. Triggers on dependency file changes, deployment prep, security mentions.

16

apollo-security-basics

jeremylongshore

Apply Apollo.io API security best practices. Use when securing Apollo integrations, managing API keys, or implementing secure data handling. Trigger with phrases like "apollo security", "secure apollo api", "apollo api key security", "apollo data protection".

13

Search skills

Search the agent skills registry