GI

grandamenium/infisical-skill

Developer tools
10 stars Quality 40 Trend 8

Infisical secret management skill for AI agents — keep API keys out of agent context

Overview

When an AI agent holds API keys in its environment variables or system prompt, those secrets are: - Visible in logs, traces, and conversation history - Copied into every subagent or spawned worker context - Exposed if a prompt injection attack extracts the context window - Rotated manually with no audit trail The blast radius of a single leaked key expands dramatically when that key lives in a long-running agent session touching dozens of services. Infisical is an open-source secret vault. Instead of baking API keys into agent context, the agent fetches each secret at the moment it is needed, uses the value in the tool call, and discards it. The secret never persists in conversation history or logs. Go to app.infisical.com and sign up (free tier available). Or self-host: see Infisical self-hosting docs. In the Infisical dashboard, create a new project (e.g., "my-agent"). Note the — you will need it. Inside the project, navigate to the environment (or create one).

README

Infisical Secret Management Skill for AI Agents

The Problem: Secrets in Agent Context Are a Security Risk

When an AI agent holds API keys in its environment variables or system prompt, those secrets are:

  • Visible in logs, traces, and conversation history
  • Copied into every subagent or spawned worker context
  • Exposed if a prompt injection attack extracts the context window
  • Rotated manually with no audit trail

The blast radius of a single leaked key expands dramatically when that key lives in a long-running agent session touching dozens of services.

The Solution: Runtime Secret Fetching via Infisical

Infisical is an open-source secret vault. Instead of baking API keys into agent context, the agent fetches each secret at the moment it is needed, uses the value in the tool call, and discards it. The secret never persists in conversation history or logs.

Agent needs Stripe key
    → calls fetch_secret("STRIPE_SECRET_KEY")
    → Infisical returns the value
    → agent uses value in Stripe API call
    → value is gone — not stored, not logged

Setup

1. Create an Infisical account

Go to app.infisical.com and sign up (free tier available). Or self-host: see Infisical self-hosting docs.

2. Create a project

In the Infisical dashboard, create a new project (e.g., “my-agent”). Note the Project ID — you will need it.

3. Add secrets

Inside the project, navigate to the prod environment (or create one). Add secrets as key-value pairs, e.g.:

OPENAI_API_KEY    = sk-...
STRIPE_SECRET_KEY = sk_live_...
SENDGRID_API_KEY  = SG....

4. Create a service token

Go to Project Settings > Service Tokens and create a token scoped to the environment your agent uses (e.g., prod, read-only). Copy the token — it starts with st..

5. Configure your agent

Set two environment variables (these are the only things agents need in context):

INFISICAL_TOKEN=st.your-service-token-here
INFISICAL_PROJECT_ID=your-project-id-here

These are low-value credentials — they grant read access only, can be rotated instantly, and carry no secret payload themselves.

Quick Start

import os
from fetch_secret import fetch_secret

token = os.environ["INFISICAL_TOKEN"]
project_id = os.environ["INFISICAL_PROJECT_ID"]

# Fetch at the moment you need it
api_key = fetch_secret("OPENAI_API_KEY", token, project_id)

# Use immediately — do not assign to a long-lived variable
response = openai_client.chat.completions.create(
    model="gpt-4o",
    api_key=api_key,
    messages=[...]
)
# Bash version
SECRET=$(./fetch_secret.sh OPENAI_API_KEY)
curl -H "Authorization: Bearer $SECRET" https://api.openai.com/...
unset SECRET

Files in This Skill

File Purpose
fetch_secret.py Python implementation using the Infisical v3 API
fetch_secret.sh Bash/curl implementation for shell-based agents
SKILL.md Agent-readable skill documentation
example_usage.md Before/after examples with real agent patterns
View the full README on GitHub

Recommended Tools

Try a different keyword or remove a filter.

Install

npx skillfish add grandamenium/infisical-skill
New to MCP? Start with the mcpskill.org guide →