Index of every page on this site: llms.txt
All skills
tkhq avatar

/managing-secrets

@6fd5c16
by Turnkeytkhq/tk72 stars
3
Run it yourself

Grant agents Turnkey Secrets exports and import, export, rotate, and inject secrets with tk, including the export policies per approval column, scope isolation between agents, secret env as a process's startup environment, and finishing an approval-gated export. Use to let an agent read a value, store one, give a process its environment, complete a pending export, or replace a value; not for wallet or private-key export.

  • 1 file
  • 10.4 KB
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/tkhq/tk/managing-secrets

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈111 tokens for metadata: the name and description. ≈2.6k when used: this file.

Description uses 5.5% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈443 characters, or 5.5%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Managing secrets

Result: named, property-tagged secrets that the right agent reads at startup with one command, with approval-gated values handled by rerunning that same command after a human approves, and an acceptance test proving the export policies from the agent's own credential.

Reference

  • secrets: secret command records, secret env quoting, and pending-export state.
  • resources: policy create flags and records.
  • activities: activity approve on a pending export and policy evaluations for a denial.

Rules

  • Values never enter the transcript. Import from --from-file or a pipe; export to --out or into the consuming process. Verify by exit code and metadata.
  • Every secret carries exactly one consensus property, unilateral or approval, and is named <scope>/<VAR> so secret env can build an environment. Properties are immutable and policy-visible; never put a secret value in one.
  • Export and env are rerun, not resumed: the same credential from the same home directory picks up its own pending export.
  • Access is granted by policy on the property, not by name prefix. The prefix selects; the policy authorizes.
  • Every acceptance check runs with --profile agent. A root success proves nothing, because a satisfied root quorum bypasses policies.

Instructions

Inputs: the root profile (admin), an agent identity from provisioning-agent-identity or provisioning-session-agent (its profile agent and AGENT_TAG), HUMAN_APPROVER_TAG from bootstrapping-organization, the export column chosen from approval-models.md, the scope prefix (service/), and for each value its file and approval level.

  1. Allow agents to export. Root. From policy-patterns.md create agents-export-unilateral for the unilateral column, agents-export-with-approval for the human column, or both when the organization holds both kinds of secrets. Skip a policy that already exists with the same name; the tag makes it shared by every agent.

  2. Import a value. Root, from a file the agent must not read:

    <!-- example: secrets.import -->
    tk --profile admin --message-format json secret import --name service/API_TOKEN --property consensus=unilateral --from-file ./api-token.txt
    tk --profile admin --message-format json secret import --name service/DEPLOY_KEY --property consensus=approval --from-file ./deploy-key.txt

    Each record is command: "secret.import" with data.secretId, data.name, and data.activity. Import is not idempotent; a pending import is waited on, never repeated. Add further --property flags for isolation scopes the policies select.

  3. List metadata. Any identity.

    <!-- example: secrets.list -->
    tk --profile agent --message-format json secret list --limit 100

    data.secrets[] carries secretId, name, staticProperties[] (key, value), and createdAtUnixMs; data.nextCursor pages. Values are never listed.

  4. Accept from the agent credential. With one secret of each level imported:

    <!-- example: secrets.acceptance -->
    tk --profile agent --message-format json secret export --name service/API_TOKEN --out ./api-token
    tk --profile agent --message-format json secret export --name service/DEPLOY_KEY --out ./deploy-key

    The unilateral export returns completed with data.out. The approval export returns pending with activity.id and stays pending until a non-root human-approver votes; finish it as in step 6. Any other outcome is a policy defect; do not proceed on it.

  5. Build the agent's environment. The agent's process, at startup:

    <!-- shared: secret-env-startup --> <!-- example: secrets.env -->
    tk --profile agent --message-format json secret env --name-prefix service/ --property consensus=unilateral

    Exit 0: data.env maps each VAR to its value and data.exported[] names the secrets; in human mode the same command prints dotenv lines for the process to source. The property filter excludes approval-gated secrets silently. Without the filter, any approval-gated secret in the selection makes the command exit 1 with code: "approval_required" and details.pending[] (name, secretId, activityId), and prints no values at all.

  6. Finish an approval-gated read. Submitter runs the export; a human approves; the submitter reruns the identical command:

    <!-- example: secrets.export-approved -->
    tk --profile agent --message-format json secret export --name service/DEPLOY_KEY --out ./deploy-key
    tk --profile approver --message-format json activity approve --id ACTIVITY_ID
    tk --profile agent --message-format json secret export --name service/DEPLOY_KEY --out ./deploy-key

    The first run returns status: "pending", activity.id, and data.nextStep; nothing is written. The rerun returns completed with data.out. --out refuses an existing path. Rerunning while the approval is outstanding returns the same pending activity, not a second one.

  7. Isolate agents from each other, when more than one exists, as in policy-patterns.md, with BILLING_AGENT_TAG set to the billing agent's tag id from user tag create:

    <!-- example: secrets.isolation -->
    tk --profile admin --message-format json policy create --name billing-agent-export --effect allow \
      --consensus "approvers.any(user, user.tags.contains('${BILLING_AGENT_TAG}'))" \
      --condition "activity.type == 'ACTIVITY_TYPE_EXPORT_SECRETS' && secret.static_properties['consensus'] == 'unilateral' && secret.static_properties['scope'] == 'billing'"
    tk --profile billing --message-format json secret export --name ops/TOKEN
    tk --profile billing --message-format json secret env --name-prefix ops/

    Both commands as the other agent fail with unauthorized 403.

  8. Rotate a value. Root. Secrets are immutable and names are unique, so a rotation is a delete followed by an import under the same name with the same properties. The name is unavailable between the two.

    <!-- example: secrets.rotate -->
    tk --profile admin --message-format json secret delete --name service/API_TOKEN
    tk --profile admin --message-format json secret import --name service/API_TOKEN --property consensus=unilateral --from-file ./api-token-new.txt

    Wait for a pending deletion before importing. The new secret has a new id. Deleting does not revoke a value already exported; rotate the credential at its provider first when access is being reduced.

  9. Hand off. Report the export policy ids and the approval column in force, each secret's id, name, and properties, the acceptance results from step 4, the pending activity ids still awaiting approval, and the exact secret env command the process runs. Stop.

Runtime examples

The process, not the agent in conversation, runs step 5 and sources its output. Hermes Agent, for example, takes the command as secrets.command; a systemd unit, for example, runs it in ExecStartPre and writes to an EnvironmentFile. Approval-gated secrets stay out of startup paths that cannot wait.

Verified by

Examples Test
secrets.import, secrets.list, secrets.env, secrets.rotate secrets::managing_secrets_env_and_rotation
secrets.acceptance secrets::managing_secrets_agent_export_acceptance
secrets.export-approved secrets::secret_export_with_consensus_finishes_by_rerunning_the_command
secrets.isolation secrets::managing_secrets_isolation_denies_cross_agent_export
secrets.env secrets::secret_env_exports_matching_secrets_as_dotenv

Troubleshooting

  • secret env exits 1 with approval_required: an approval secret is in the selection. Either add --property consensus=unilateral for the startup path, or approve each details.pending[].activityId and rerun.
  • secret export fails with unauthorized 403: no export policy selects this user for this secret's properties. Check the secret carries the consensus property and the policy's AGENT_TAG is the id, not the name. Inspect tk --profile admin --message-format json policy evaluations --activity-id ACTIVITY_ID when the error carries an activity; otherwise compare the user's tags with the policy consensus. Do not switch to root.
  • secret export fails with api_error and details.activity: the export was rejected or failed; local state is cleared and the next run starts a new export.
  • secret import fails with api_error 400: the name is taken. A pending deletion holds the name until it completes.
  • secret env fails with invalid_input "no secrets match": the prefix or property selects nothing in this organization. Check secret list.
  • The approval export returns completed without a human vote: the approver is root, or the secret carries consensus=unilateral. Fix the property or the approver; root approval proves nothing.
  • secret env fails with unauthorized 403: the prefix selected a secret outside this agent's scope. Narrow the prefix or fix the scope property.
  • secret export from a different machine or profile returns a new pending: pending state belongs to the credential and home that started it. Finish from the original.

Related Skills

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 6fd5c16. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated last month

README badge

README badge for tkhq/tk/managing-secrets