Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/golid-ai/golid/external-apigit clone --depth 1 https://github.com/golid-ai/golidWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.00604 |
| Opus 5 | $0.00000 | $0.00302 |
| Sonnet 5 | $0.00000 | $0.00121 |
| Haiku 4.5 | $0.00000 | $0.00060 |
Grade A, and why
external-api scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 68 lines — stays where its author put it; the contents beside it link to each section on GitHub.
External API Integration Patterns
Thesis: External services are wrapped with IsConfigured(), env-sourced credentials, and graceful degradation when unconfigured.
Service Wrapper Structure
type XService struct {
apiKey string
configured bool
client *http.Client
}
func NewXService(apiKey string) *XService {
if apiKey == "" {
slog.Warn("X not configured — feature will be disabled")
return &XService{configured: false}
}
return &XService{apiKey: apiKey, configured: true, client: &http.Client{Timeout: 30 * time.Second}}
}
func (s *XService) IsConfigured() bool { return s.configured }
Every method must check IsConfigured() first and return a clean error, not panic.
Config Flow
API keys and secrets flow: env var → Config struct → service constructor → wire.BuildServices.
.env.local: EXTERNAL_API_KEY=xxx
config.go: ExternalAPIKey string → os.Getenv("EXTERNAL_API_KEY")
wire/services.go: externalService := external.NewExternalService(cfg.ExternalAPIKey)
Template IDs, webhook secrets, and other per-service config follow the same pattern. Never hardcode in service files.
Request Building
- Verify field names against the actual API docs. JSON struct tags must match exactly (e.g.,
roleIndexnotrole_index). - Query params vs body — some APIs put IDs in the URL, not the body. Check the docs.
- URL-encode all query parameter values with
url.QueryEscape(). - Set timeouts on the HTTP client (30s default).
- Close response bodies with
defer resp.Body.Close().
Webhook Handling
- Verify signatures — HMAC-SHA256 with timing-safe
hmac.Equal. Read raw body withio.ReadAllbefore parsing. - Return 200 on parse errors — prevents the external service from retrying malformed events indefinitely.
- Return 500 on handler errors — signals the external service to retry.
- Register on public route group — webhooks don't have JWT auth, they use their own signature verification.
- Exclude from gzip middleware — webhook bodies need to be read raw for signature verification.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 68 lines · 0 tokens per session scan A 591f2687ef8a
external-api is a cursor rule published in the GitHub repository golid-ai/golid (40 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 604 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
cursorrules
AGENTS.md.
adapter-features
Database-specific features must be implemented in the specialized adapter only. Base adapters (postgres, mysql, etc.) must remain database-agnostic.
git-commits
Git commit safety — commits are human-only; AI suggests, never executes.
unit-tests-tdd
TDD required for behavior changes; ≥80% package coverage on touched packages; unit-test conventions.
token-optimization
Agent-mode tool-call efficiency. Cuts the largest hidden cost in modern AI IDEs — wasted tool calls and oversized context windows.
config-resilience
Config warn-and-continue for non-sensitive keys; Auth/ACL/JWT/secrets/DB credentials fail closed.