modal-secrets
Skill4 starsChanged 4 months agoApache-2.0View on GitHub
Secure credential and secret management on Modal. Use when providing API keys, database credentials, or tokens to Modal Functions, managing secrets via dashboard/CLI/code, or configuring OIDC authentication.
- Reads credentials
In this repository80 other files it gives its agents.
- a11y-accessibility-designSkill
- agentic-ui-patternsSkill
- ai-native-ui-designSkill
- ai-ui-anti-patternsSkill
- ai-ui-heuristicsSkill
- calm-technology-uiSkill
- conversion-growth-designSkill
- cross-platform-designSkill
- dark-mode-designSkill
- data-visualizationSkill
- design-systemsSkill
- design-thinking-processSkill
- error-empty-statesSkill
- ethical-design-patternsSkill
- form-uxSkill
- information-architectureSkill
- interaction-design-patternsSkill
- internationalization-uiSkill
- mobile-touch-designSkill
- modal-classes-lifecycleSkill
- modal-container-imagesSkill
- modal-dicts-queuesSkill
- modal-endpointsSkill
- modal-fundamentalsSkill
- modal-gpu-computeSkill
- modal-networkingSkill
- modal-observabilitySkill
- modal-parallel-executionSkill
- modal-sandboxesSkill
- modal-scaling-performanceSkill
- modal-schedulingSkill
- modal-serversSkill
- modal-storageSkill
- modal-web-servingSkill
- modal-workspace-adminSkill
- motion-design-principlesSkill
- notifications-permissionsSkill
- onboarding-uxSkill
- rust-api-designSkill
- rust-async-programmingSkill
- rust-cargo-masterySkill
- rust-cli-applicationsSkill
- rust-clippy-lintsSkill
- rust-closures-iteratorsSkill
- rust-compiler-internalsSkill
- rust-concurrencySkill
- rust-design-patternsSkill
- rust-editionsSkill
- rust-embeddedSkill
- rust-error-handlingSkill
- rust-game-developmentSkill
- rust-lifetimes-borrowingSkill
- rust-macrosSkill
- rust-performanceSkill
- rust-rustdocSkill
- rust-rustup-toolchainSkill
- rust-smart-pointersSkill
- rust-testing-benchmarkingSkill
- rust-type-systemSkill
- rust-unsafe-ffiSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill when managing credentials, API keys, tokens, or other sensitive configuration for Modal Functions.
- Very specific: line 168
Check secret name matches: modal secret list
- Distinctive: line 169
Verify key name in the secret matches what you access
- Very specific: line 170
Ensure secrets=[...] is in the function decorator
- Distinctive: line 173
Check environment: secrets are environment-scoped
- Very specific: line 174
Use --env flag or environment_name= parameter
- Distinctive: line 183
Never hardcode secrets in source code
- Very specific: line 184
Use from_name for production.
- Distinctive: line 186
Use the dashboard for secure secret editing (values are encrypted)
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Modal Secrets
Use this skill when managing credentials, API keys, tokens, or other sensitive configuration for Modal Functions.
When to Use This Skill
- Providing API keys or credentials to remote Functions
- Managing secrets via dashboard, CLI, or code (
create/update/delete) - Using .env files with Modal
- Configuring OIDC for cloud provider authentication
- Sharing secrets across Functions or Apps
Quick Start
@app.function(secrets=[modal.Secret.from_name("my-secret")])
def f():
import os
api_key = os.environ["API_KEY"]Creating Secrets
Dashboard (recommended for persistent secrets)
Go to modal.com/secrets. Templates available for common services (AWS, HuggingFace, Postgres, etc.).
CLI
modal secret create my-secret KEY1=value1 KEY2=value2
modal secret list
modal secret delete my-secretProgrammatically
modal.Secret.objects.create("my-secret", {"KEY": "value"})Update (Secret.update)
Merge key/value pairs into an existing named Secret (dict.update semantics — unmentioned keys are unchanged):
secret = modal.Secret.from_name("my-secret")
secret.update({"API_KEY": "rotated", "NEW_KEY": "value"})Updates apply only to containers that start after the modification — already-running containers keep the previous env.
Using Secrets
from_name (reference dashboard/CLI secrets)
@app.function(secrets=[modal.Secret.from_name("aws-creds")])
def f():
key = os.environ["AWS_ACCESS_KEY_ID"]from_dict (inline for dev/testing)
@app.function(secrets=[modal.Secret.from_dict({"FOO": "bar"})])
def f():
print(os.environ["FOO"])from_dotenv (.env files)
@app.function(secrets=[modal.Secret.from_dotenv()])
def f():
print(os.environ["DATABASE_URL"])from_local_environ (forward local env vars)
@app.function(secrets=[modal.Secret.from_local_environ(["API_KEY", "DB_URL"])])
def f():
print(os.environ["API_KEY"])Multiple secrets
@app.function(secrets=[
modal.Secret.from_name("aws"),
modal.Secret.from_name("db"),
])
def f(): ...Applied in order — later secrets override earlier ones on key collision.
App-Level Secrets
Inject secrets into all Functions in an App:
app = modal.App(secrets=[modal.Secret.from_name("shared-secret")])Go SDK
mc, _ := modal.NewClient()
// Reference named secret
secret, _ := mc.Secrets.FromName(ctx, "my-secret", &modal.SecretFromNameParams{
RequiredKeys: []string{"API_KEY"},
})
// Create inline secret
secret2, _ := mc.Secrets.FromMap(ctx, map[string]string{
"API_KEY": "abc123",
}, nil)
// Use with Sandbox
sb, _ := mc.Sandboxes.Create(ctx, app, image, &modal.SandboxCreateParams{
Secrets: []*modal.Secret{secret},
})TypeScript SDK
import { ModalClient } from "modal";
const modal = new ModalClient();
// Reference named secret
const secret = await modal.secrets.fromName("my-secret", {
requiredKeys: ["API_KEY"],
});
// Create inline secret
const secret2 = await modal.secrets.fromObject({
API_KEY: "abc123",
DB_URL: "postgres://...",
});
// Use with Sandbox
const sb = await modal.sandboxes.create(app, image, {
secrets: [secret, secret2],
});
// Delete a secret
await modal.secrets.delete("old-secret");Limits
- Key names: <=16,384 chars, letters/digits/underscores, cannot start with digit
- Values: <=32,768 chars
- For larger values, write to a Volume and read at runtime
Symptom Triage
"KeyError for environment variable"
- Check secret name matches:
modal secret list - Verify key name in the secret matches what you access
- Ensure
secrets=[...]is in the function decorator
"Secret not found"
- Check environment: secrets are environment-scoped
- Use
--envflag orenvironment_name=parameter
Reference Map
references/secrets-management.md— CRUD operations, dashboard, CLI, codereferences/oidc-integration.md— OIDC for AWS, keyless authentication
Guardrails
- Never hardcode secrets in source code
- Use
from_namefor production;from_dictfor dev/testing only - Secrets are environment-scoped — check your active environment
- Use the dashboard for secure secret editing (values are encrypted)
Secret.updateonly affects containers started after the update
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

