agentleFS
aaziraniaazirani/flutter_agentify/.agents/skills/backend-proxy/SKILL.md

backend-proxy

Skill0 starsChanged 4 days agoMITView on GitHub

What a proxy server in front of a model must do, and how to point the app's Custom preset at it. Use when an app must ship without the person supplying a key, or the app runs on web.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Don't load this for storing a key the person types.

    line 8
  2. Very specific:

    If you ship the app without asking people for a key, the key lives on a server you run, and the app talks to that server through the custom …

    line 12
  3. Very specific:

    No automated check. Test by hand with curl -N against the proxy, then in the app on a real device.

    line 41

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

Backend proxy

Don't load this for storing a key the person types; see secrets. For preset and model settings, see model-providers.

Rule

If you ship the app without asking people for a key, the key lives on a server you run, and the app talks to that server through the custom preset. No automated check covers this skill: nothing in the gate tests a proxy.

Why

A key inside the app can be extracted (secrets). Web cannot hold one at all, and browsers also block calls to servers that do not allow them (CORS). A proxy fixes both.

How

The proxy must:

  1. Accept the OpenAI-compatible request the app sends: POST <baseUrl>/chat/completions with messages, optional tools, and stream: true. OpenAiCompatibleProvider in packages/flutter_agentify_core/lib/src/llm/ is the client; read it for the exact fields.
  2. Add the key on the server and forward to the real model. With the custom preset the app sends an authorization header only if a key is saved for it; leave it empty and the proxy adds its own.
  3. Stream the reply back as server-sent events, unbuffered, and end with data: [DONE]. A proxy that buffers makes the chat look frozen.
  4. Limit use per person: sign-in or a per-device token, a request rate, and a cap on tokens. The app cannot do this for you.
  5. Send CORS headers for the web origin (and answer OPTIONS), if the app runs on web.
  6. Pass errors through with their real status (429, 5xx) so LlmError.retryable works.

Pointing the app at it: in Settings choose "Custom (OpenAI-compatible)", set the address to the proxy's /v1 root and the model name to one the proxy accepts. Set toolCalling for that model in the advanced section (lib/presentation/settings/assistant_settings_section.dart). The key is optional for custom: leave it empty, or enter a token your proxy checks (not on web). Use https:// for a proxy outside your network; the custom preset refuses http:// to a non-local host, key or not (SetAssistantProvider).

To ship the app already pointing at the proxy, set its values in lib/ai/assistant_setup.dart: ServerSetup(presetId: 'custom', baseUrl: ..., model: ...), with userEditable: false when the person must not change them. Never add a key there. The address is public, so protect the proxy itself with limits.

Anti-patterns

  • A proxy with no per-person limit: anyone who finds the address spends your money.
  • Putting the real key in the app "just for the demo".
  • Rewriting the request into another format in the app; keep the app speaking the one format and translate on the server.

Verification

  • No automated check. Test by hand with curl -N against the proxy, then in the app on a real device.
  • For app-side behavior against a fake server, see the helpers in packages/flutter_agentify_core/test/llm/fake_llm_server.dart.

Related skills

  • secrets — why the key stays off the device
  • model-providers — the Custom preset and web limits
  • permissions-and-platform — cleartext and local-network settings for non-HTTPS addresses

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.