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

/managing-policies

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

Write, apply, inspect, update, and debug Turnkey policies with tk, including consensus that requires a human approver and policy evaluations for a denied activity. Use to grant or restrict what a tagged user may do or to explain a denial; not for choosing an approval model, which the bootstrap workflow covers.

Use this Skill: https://skilld.dev/gh/tkhq/tk/managing-policies

Nothing lands on disk. Nothing to clean up.

Fork this Skill

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

SKILL.md

≈83 tokens for metadata: the name and description. ≈1.4k when used: this file.

Description uses 4.1% 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 ≈331 characters, or 4.1%.

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 policies

Result: a policy set that grants the intended access and nothing more, tested from a non-root credential, with denials explained by policy evaluations.

Reference

  • resources: policy command records and update field names.
  • activities: policy evaluations and consensus votes.

Rules

  • Write policies against tag ids and secret static properties. Name a user or resource id only where the reference says it is unavoidable.
  • A DENY overrides every ALLOW. Never delete a containment DENY to make an activity succeed.
  • Consensus must contain a clause the submitter satisfies, or the activity is denied at submission instead of waiting for approval.
  • Test from the constrained credential. Root success proves nothing about agent access.
  • Keep expressions exactly as written; only the ${UPPER_SNAKE} id variables interpolate.

Instructions

Inputs: the root profile (admin), AGENT_TAG and the other tag ids from bootstrapping-organization, and the approval cell. Read policy-language.md for grammar and policy-patterns.md for the policy set.

  1. State the change. Before any mutation, write down effect, condition, consensus, and which users the consensus selects. If the request is "make this denied activity work", read the denial first (step 5) and return the smallest change that fits the requested access.

  2. Create a policy. Root. Flags for one policy:

    <!-- example: policies.create -->
    tk --profile admin --message-format json policy create --name agents-export-unilateral --effect allow \
      --consensus "approvers.any(user, user.tags.contains('${AGENT_TAG}'))" \
      --condition "activity.type == 'ACTIVITY_TYPE_EXPORT_SECRETS' && secret.static_properties['consensus'] == 'unilateral'" \
      --notes "allow-always: agents read unilateral secrets alone"

    Save data.activity.result.createPolicyResult.policyId. For several policies at once, policy create-batch --input-file ./policies.json takes {"policies":[...]} with policyName, effect, condition, consensus, notes.

  3. Confirm what was stored.

    <!-- example: policies.get -->
    tk --profile admin --message-format json policy get --id POLICY_ID
    tk --profile admin --message-format json policy list

    data.policy.condition and data.policy.consensus must equal the expressions from step 1 character for character.

  4. Test from the constrained credential. Run the intended allowed operation and one operation that must be denied as the tagged user. The allowed one returns status: "completed" or, for allow-once, pending; the denied one fails with unauthorized and HTTP 403.

  5. Explain a denial or a pending vote.

    <!-- example: policies.evaluations -->
    tk --profile admin --message-format json policy evaluations --activity-id ACTIVITY_ID

    data.policyEvaluations[] carries one entry per vote with policyEvaluations[].policyId and outcome. A DENY outcome names the policy to read; no ALLOW outcome means no policy matched. A 403 with no activity id means the request was refused before an activity existed; compare the submitter's tags against the consensus clauses.

  6. Update or delete. Root. Updates use policyId with the policy-prefixed field names:

    <!-- example: policies.update -->
    tk --profile admin --message-format json policy update --input-json '{"policyId":"POLICY_ID","policyNotes":"revised"}'
    tk --profile admin --message-format json policy delete --id POLICY_ID

    Re-run step 3 after an update. Deleting an ALLOW removes access immediately; deleting a DENY may widen access, so re-run step 4.

  7. Hand off. Report each policy id with its name, effect, condition, and consensus, and the allowed and denied operations that were tested. Stop.

Verified by

Examples Test
policies.create, policies.get, policies.evaluations, policies.update policies::managing_policies_crud_and_evaluations
policies.evaluations policies::quorum_approval_completes_and_rejection_fails_a_consensus_activity

Troubleshooting

  • policy create fails with usage_error: --name needs --effect and at least one of --condition or --consensus.
  • policy update fails with invalid_input naming an unsupported field: updates use policyEffect, policyCondition, policyConsensus, and policyNotes, not the create names.
  • The constrained user gets unauthorized on an operation the ALLOW covers: check activity.type spelling against the table in policy-language.md, and check that the user actually carries the tag with tk --profile admin --message-format json user get --id USER_ID.
  • The activity is pending when it should complete: the consensus names a second party. That is allow-once behavior; approve it, or change the consensus if unilateral was intended.
  • The activity is denied when it should be pending: no consensus clause is satisfiable by the submitter. Add the submitter's tag clause.
  • A root user approves and everything passes: the root quorum bypassed the policies. Repeat the test with a non-root approver.

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