agentleFS
vhmarquezvhmarquez/argo/skills/gateway-config/SKILL.md

gateway-config

Skill1 starsChanged 7 months agoMITView on GitHub

Generate (or validate) the LLM Governance on AI Gateway configuration for the project — token quotas, model allowlist, fallback policy, per-agent rate limits. Output is a `.claude/ai-gateway.<env>.json` file the org's gateway service consumes.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Default model is in the allowlist

    line 98
  2. Distinctive:

    Default Markdown after generate:

    line 106

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

You are producing the AI Gateway configuration that controls token usage, model selection, and fallback behavior for agents in this org. The gateway is the org-level chokepoint for LLM traffic — sensible defaults here prevent surprise bills and cap blast-radius for misbehaving agents.

Read Project Config First

source "${CLAUDE_PLUGIN_ROOT}/hooks/lib/config.sh"
PROJECT_NAME="$(sf_config_get '.project.name' "$ENV")"
DEFAULT_ENV="${ENV:-base}"

The output path follows the env-override convention:

  • --env prod → writes .claude/ai-gateway.prod.json
  • (no env) → writes .claude/ai-gateway.json (the base config)

Per-env overrides deep-merge over the base in the same way sf-project.<env>.json does.

Input

$ARGUMENTS:

  • (empty) — interactive walk through the sections below
  • --profile dev|qa|prod — apply a recommended bundle (see below)
  • --validate — verify the existing gateway config; no changes
  • --env <name> — write to env override file
  • --ci — non-interactive, profile or explicit fields required

Configuration sections

Models

FieldPurposeDefault
models.allowlistModels permitted from this org["sf-proprietary","claude-sonnet","gpt-5"]
models.defaultDefault for non-specialized work"sf-proprietary"
models.byAgentPer-agent model override{}

Quotas

FieldPurposeDefault (dev / prod)
quotas.tokensPerHour.orgOrg-wide ceiling1_000_000 / 10_000_000
quotas.tokensPerHour.perAgentPer-agent ceiling100_000 / 1_000_000
quotas.requestsPerMinute.perAgentPer-agent rate limit60 / 600
quotas.maxContextTokensPer-request context cap100_000
quotas.maxOutputTokensPer-response output cap4_096

Fallback

FieldPurposeDefault
fallback.policyWhat to do when primary model fails or quota exceeded"degrade" (use cheaper model)
fallback.chainOrdered fallback list["claude-sonnet","gpt-5","sf-proprietary"]
fallback.refuseAfterStop trying after N attempts3
fallback.userMessageMessage shown when refusing"I'm temporarily unavailable. Please try again in a minute."

Audit

FieldPurposeDefault
audit.logAllRequestsLog every request for compliancetrue
audit.retainDaysLog retention90 (dev) / 365 (prod)
audit.alertWebhookWebhook for quota-exceeded events(project's notifications.webhooks.slack)

Profiles

ProfileToken / hour capModelAudit retention
dev1Msf-proprietary (cheap, fast iteration)30d
qa5Mclaude-sonnet60d
prod10Mclaude-sonnet (with gpt-5 fallback)365d

Each profile is a JSON template under ${CLAUDE_PLUGIN_ROOT}/templates/gateway/<profile>.json (the skill copies + merges).

Steps

--profile prod

  1. Read template ${CLAUDE_PLUGIN_ROOT}/templates/gateway/prod.json
  2. Substitute project-specific fields:
    • audit.alertWebhook ← notifications.webhooks.slack from sf-project.json
    • models.byAgent ← infer from botDefinitions/ (if there are agents in source)
  3. Write to .claude/ai-gateway.prod.json

Interactive (no profile)

Walk through each section, showing defaults from the closest matching profile, asking the user to override or accept.

--validate

  1. Load current .claude/ai-gateway[.<env>].json
  2. Cross-check against constraints:
    • Each agent in botDefinitions/ is either in the allowlist or has a per-agent model override
    • Default model is in the allowlist
    • Fallback chain doesn't include disallowed models
    • Token quotas are positive and per-agent ≤ org-wide
    • notifications.webhooks.slack resolves (if used)
  3. Report findings with rule IDs GATEWAY-AGENT-NO-MODEL, GATEWAY-FALLBACK-DISALLOWED, GATEWAY-QUOTA-INVERTED, etc.

Output

Default Markdown after generate:

# AI Gateway Config: <project.name> (env=prod)

✅ Wrote .claude/ai-gateway.prod.json (merged template + project context)

Models:
- Allowlist:        claude-sonnet, gpt-5, sf-proprietary
- Default:          claude-sonnet
- Per-agent:        order_helper → claude-sonnet, support_triage → claude-sonnet

Quotas:
- Org tokens/hour:  10,000,000
- Per-agent:        1,000,000
- Per-agent rate:   600 req/min
- Max context:      100,000 tokens
- Max output:       4,096 tokens

Fallback:
- Policy:           degrade
- Chain:            claude-sonnet → gpt-5 → sf-proprietary → refuse
- Refuse after:     3 attempts

Audit:
- Log all:          true
- Retain:           365 days
- Alert webhook:    https://hooks.slack.com/... (from notifications.webhooks.slack)

## Next steps
- Apply via the org's AI Gateway admin (Setup → Einstein → AI Gateway → Import)
- Schedule periodic /argo:gateway-config --validate runs to detect drift
- Review /argo:trust-eval reports to tune token quotas based on actual usage

--validate output:

# Gateway Config Validation: <project.name> (env=prod)

✅ Allowlist:    valid
✅ Default model: in allowlist
✅ Fallback chain: in allowlist
⚠️ Per-agent override: support_triage references "claude-haiku" not in allowlist (GATEWAY-FALLBACK-DISALLOWED)
✅ Quotas:       per-agent ≤ org-wide
✅ Webhook:      resolves

Exit codes

  • 0 — config written or validate clean
  • 1 — --validate found issues
  • 2 — invocation error

Rules

  • Don't write secrets. Webhook URLs are sensitive; the file should reference ${SLACK_WEBHOOK_URL} env var indirection rather than the literal URL where possible
  • Per-env scoping is normal. dev caps low; prod caps high. Use override files
  • Don't auto-apply. This skill writes config; an operator imports it into the org's Gateway. Don't try to PUT it via API automatically (gateway changes are operator decisions)
  • Validate before deploy. Recommend running --validate on PR; failed validation blocks the merge in CI
  • Quotas are guardrails, not optimization. Set them generously enough that legitimate users don't hit them, low enough that runaway agents can't drain credits

Consumers

  • Gateway operators (admins) import the JSON via Setup
  • /argo:agent-deploy cross-references the agent against the gateway model allowlist; warns if a deployed agent references a non-allowed model
  • /argo:trust-eval references quota-exceeded events captured in the audit log

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.