agentleFS
botirkhaltaevbotirkhaltaev/botir-skills/skills/modal-secrets/SKILL.md

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

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
  1. Distinctive:

    Use this skill when managing credentials, API keys, tokens, or other sensitive configuration for Modal Functions.

    line 8
  2. Very specific:

    Check secret name matches: modal secret list

    line 168
  3. Distinctive:

    Verify key name in the secret matches what you access

    line 169
  4. Very specific:

    Ensure secrets=[...] is in the function decorator

    line 170
  5. Distinctive:

    Check environment: secrets are environment-scoped

    line 173
  6. Very specific:

    Use --env flag or environment_name= parameter

    line 174
  7. Distinctive:

    Never hardcode secrets in source code

    line 183
  8. Very specific:

    Use from_name for production.

    line 184
  9. Distinctive:

    Use the dashboard for secure secret editing (values are encrypted)

    line 186

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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-secret

Programmatically

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 --env flag or environment_name= parameter

Reference Map

  • references/secrets-management.md — CRUD operations, dashboard, CLI, code
  • references/oidc-integration.md — OIDC for AWS, keyless authentication

Guardrails

  • Never hardcode secrets in source code
  • Use from_name for production; from_dict for dev/testing only
  • Secrets are environment-scoped — check your active environment
  • Use the dashboard for secure secret editing (values are encrypted)
  • Secret.update only affects containers started after the update

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.