Claude Skills Guide

Claude MD Secrets and Sensitive Info Handling

When you build Claude skills as Markdown files, you often need to work with API keys, database credentials, tokens, and other sensitive information. This guide covers practical patterns for handling secrets securely in your Claude skill workflows without exposing credentials to logs, outputs, or unintended parties.

Why Secret Handling Matters in Claude Skills

Claude skills live as plain Markdown files in your ~/.claude/skills/ directory. Any credentials embedded directly in these files get loaded into Claude’s context during every session. This creates several risks: credentials appear in conversation history, get included in potential AI training data, and may leak through error messages or debug outputs.

The solution is never embedding secrets directly in your skill files. Instead, use environment variables, secure vaults, or external configuration files that Claude reads at runtime.

Environment Variables: The Foundation

The most straightforward approach uses environment variables. Claude automatically inherits all exported environment variables from your shell, making them accessible without modification to your skill files.

Create a skill that references these variables:

# API Client Skill

You are an API client helper. Use the following configuration:

- API endpoint: ${API_ENDPOINT}
- Timeout: ${API_TIMEOUT:-30} seconds
- Retry attempts: ${API_RETRIES:-3}

When making requests, always:
1. Check that required environment variables are set
2. Use the timeout value from API_TIMEOUT
3. Handle errors gracefully with the configured retry logic

The ${VAR:-default} syntax provides fallback values when variables are unset. This pattern works well for configuration values but should never include actual secret values—even as fallbacks.

For actual secret access, check for required variables at the start of your session:

# AWS Operations Skill

Before performing any AWS operations, verify:

- AWS_ACCESS_KEY_ID is set
- AWS_SECRET_ACCESS_KEY is set
- AWS_REGION is set

If any required variables are missing, respond with a clear error message listing the missing variables. Do NOT proceed with any operations until all required credentials are available.

Using .env Files with Dotenv Skills

For projects using the dotenv pattern, create a skill that loads environment variables from a .env file. This skill helps Claude understand how to work with your project’s configuration:

# Dotenv Project Skill

This project uses a .env file for configuration management.

When working with environment variables:
1. Never log or display the contents of .env files
2. Never include actual values in explanations or summaries
3. Refer to variables by name only (e.g., "the DATABASE_URL variable")
4. If asked to show configuration, respond with variable names only

The .env file should contain:
- DATABASE_URL
- API_SECRET_KEY
- ENCRYPTION_KEY
- Third-party service tokens

This approach keeps secrets on your local filesystem while giving Claude the context it needs to work with them properly.

The SuperMemory Skill for Encrypted Notes

For more sophisticated secret management, consider integrating with password managers or encrypted note systems. The supermemory skill can help organize sensitive information in an encrypted format that Claude can access without exposing raw secrets.

Store sensitive configuration details in your password manager, then use Claude to retrieve them through secure channels. The skill can guide Claude to use command-line password tools like pass or API-based secrets retrieval:

# Secrets Retrieval Skill

When you need to access secrets during a session:

1. Use `pass show service/name` to retrieve stored credentials
2. Never type out or display full secret values
3. Use secrets only for the specific operation requiring them
4. Clear any temporary references after use

Example workflow:
- User asks to deploy to production
- You retrieve the deployment API key using pass
- You use the key for the deployment operation only
- You do not retain or log the key after the operation completes

Integrating with HashiCorp Vault

For enterprise environments, Vault provides a robust secrets management solution. Create a skill that establishes Vault integration patterns:

# Vault-Enabled Operations Skill

This environment uses HashiCorp Vault for secrets management.

Workflow for accessing secrets:
1. Authenticate to Vault using the configured method (token, AppRole, etc.)
2. Read secrets from the appropriate path (e.g., secret/data/myapp/api-keys)
3. Use the retrieved values for the immediate task
4. Ensure values are never logged, stored, or transmitted beyond immediate use

Always use Vault's temporary credentials when available (e.g., Vault agent injects).
Avoid hardcoding Vault addresses or tokens in skill files.

This pattern scales well for teams requiring centralized secrets management with audit trails and rotation policies.

Claude Code’s Built-in Secret Handling

Claude Code itself provides some secret handling capabilities through its conversation context management. However, you should treat the following as永远不会 permanent storage:

Always assume that anything typed or displayed in a Claude session could be captured somewhere. This mindset prevents accidental secret exposure.

Practical Example: API Integration Skill

Here’s a complete example showing secure API integration:

# API Integration Helper

You help integrate with external APIs securely.

## Required Setup

Before making API calls, ensure these environment variables exist:
- API_BASE_URL (the base endpoint)
- API_KEY (your authentication token)

## Making Requests

When the user requests an API call:
1. Confirm both required variables are set
2. Construct headers including Authorization: Bearer $API_KEY
3. Make the request to $API_BASE_URL/endpoint
4. Handle responses without logging credentials

## Error Handling

If authentication fails:
- Do NOT display the API key in error messages
- Suggest checking if API_KEY environment variable is correct
- Offer to validate the variable format without revealing its value

Temporary Secret Patterns

Sometimes you need to work with temporary secrets during a session. Use these patterns:

# Temporary Credential Skill

When用户提供临时凭证:
1. Use the credential for the immediate operation only
2. Do not store or remember the credential after the task completes
3. If the credential appears in any output, redact it before displaying
4. Recommend the user rotate the credential if it was shared verbally

Best Practices Summary

Following these patterns keeps your Claude skill workflows secure while maintaining the flexibility needed for complex development tasks. The key principle: secrets should flow through Claude’s context without ever being written to persistent storage beyond your secure vault.

Built by theluckystrike — More at zovo.one