agent-security-hardening
AFaffaan-m/ECC315k4,381 new stars in the last 7 days
Decide whether a system needs a backend-for-frontend, how many, and what each one may own: adoption signals and honest costs, one-experience-one-BFF granularity with frontend-team ownership, the shape-don't-decide rule, upstream aggregation with partial-failure and resilience budgets, identity-keyed BFF caching, mediating user identity toward upstream services (token exchange, confused-deputy prevention), and the alternatives (shared gateway, GraphQL federation, token-mediating backend, direct SPA→API, meta-framework server as BFF). Use when adopting or splitting BFFs, aggregating upstream services, handling upstream failures, forwarding user identity downstream, weighing GraphQL against per-client BFFs, or auditing a BFF that has drifted into a public API or a business-logic layer. For protecting the BFF's own entry points use bff-entry-points; for physical route layout use structure-codebase; for externally consumed API contracts use api-design; for OAuth/OIDC protocol flows use secure-oauth-oidc.
A backend-for-frontend is an ownership pattern before it is a technology: the API a client application uses is part of that application, owned by the team that owns the frontend, and consumed by no other application (Calçado, the pattern's originator). Architecturally it is a driving host for one user experience — it shapes, aggregates, and mediates; it does not decide.
This skill owns the pattern-level decisions: whether to have a BFF, how many, what each may own, how it aggregates and survives upstream failure, and how it carries user identity toward upstream services. Load bff-entry-points for protecting the BFF's own boundary — access classification, the prepared registrar, sessions/CSRF, realtime protection, enforcement gates; nothing in this skill repeats it. Load structure-codebase for the physical endpoints/ tree, hexagonal-architecture for the driving-host framing, api-design for contracts with consumers you do not control (which a healthy BFF never has), and secure-oauth-oidc for the OAuth/OIDC protocol invariants behind everything in the upstream-identity reference.
Read the relevant reference before deciding:
references/adoption-and-granularity.md when deciding whether to adopt, how many BFFs to run, who owns them, mobile version skew, and the deployable-vs-module sizing call.references/aggregation-and-resilience.md when a BFF fans out to upstream services: composition, partial failure, timeout/retry budgets, and caching.references/upstream-identity.md when the BFF calls upstream services on behalf of a user: token exchange, scope narrowing, confused-deputy prevention, revocation propagation.references/alternatives.md when weighing a BFF against a shared gateway, GraphQL federation, a token-mediating backend, direct SPA→API, or a meta-framework server.| Signal | Reading |
|---|---|
| A second client type is arriving (mobile app, partner surface, TV) | Strongest adoption trigger — Newman: consider a BFF for each party from the outset |
| One page/screen fans out to many downstream calls | Aggregation belongs server-side, near the services, shaped per experience |
| Frontend teams queue behind a general-purpose API team for every endpoint | The SoundCloud problem — a BFF moves the contract inside the frontend team |
| Browser app handles sensitive/personal data (default: any app with logins qualifies) | The IETF browser-apps BCP-track guidance strongly recommends the BFF architecture on security grounds alone — tokens stay server-side |
| Only one interface, making simple, similar requests to one backend | Skip it — Azure's explicit "not suitable" case — unless another row fires: the rows answer different questions, and the security row alone justifies a BFF for a sensitive single-backend SPA (token confinement needs no aggregation motive) |
| You already run GraphQL with frontend-specific resolvers, or a meta-framework server (Next/Remix/SvelteKit) | You may already have a BFF — apply this skill to it instead of adding another box |
A meta-framework server is a BFF: Remix documents its server as exactly this, and Next.js route handlers carry the same responsibilities (and the same risks — they are publicly reachable by default, so bff-entry-points applies to them unchanged).
The unit of granularity is the experience — one coherent product surface, whatever platforms render it. iOS and Android listener apps rendering the same experience are one consumer with two builds, not two consumers; the creator app is a different experience and gets its own BFF (SoundCloud's practice, Newman's rule).
The BFF owns presentation-model work: aggregation, reshaping, payload thinning, per-experience defaults, and translating upstream results into what one UI renders. It does not own:
bff-entry-points, hexagonal reference); the BFF contributes an honest principal, nothing more.Decision-shaped logic goes down into a domain service immediately, duplication or not — the ladder governs only presentation-adjacent duplication. When such logic appears in a second BFF, resist merging BFFs upward — "highly bloated code with multiple concerns squashed together" (Newman). The remedy ladder: tolerate the duplication first; extract a shared library only for non-domain plumbing (and beware upgrade cascades across BFFs); at the third occurrence — rule of three — ask whether the repeated logic was domain-shaped all along, and if so push it down into a domain service beneath all BFFs. The rule of three schedules abstraction of presentation plumbing; it never grants business or authorization decisions three free passes.
Each of these compresses a reference section with sources and mechanics — read the reference before implementing.
The moment a second experience consumes a BFF, it stops being one: the contract freezes, the coordination tax returns, and "part of the application" silently becomes an unversioned public API. Guardrails, all three:
bff-entry-points) excludes browser-origin cross-surface misuse, and a mobile BFF accepts only user bearer tokens whose issuer, audience, and authorized-party claims name its surface. A determined scripted client that obtains its own session is governed by these policies plus abuse controls, not cryptographically excluded — say so in the threat model instead of overclaiming. Attestation APIs and client telemetry are risk signals on top, never verified identity.api-design). A data feed is neither an experience nor the BFF's to serve: front it from the domain services — the BFF holds no durable state to feed from.observability for the wide-event shape); an unfamiliar registration or credential mode in BFF telemetry is an architectural incident, not a support question.Recovering from drift (the audit case — a second consumer is already coupled): declare it, freeze the contract additively, stand up the consumer's own surface (its BFF or a public API), migrate it strangler-style route by route with a published deprecation date, and only then enforce the boundary rejection. Enforcing first breaks a consumer you accepted; never enforcing means the drift is now the architecture.
X-User-Id header.bff-entry-points?bff-entry-points to it rather than treating it as "just the frontend"?AFaffaan-m/ECC315k4,381 new stars in the last 7 days
Audit the whole repo: find bugs, security holes and performance bottlenecks. Get a ranked report in plain English.
DIDietrichGebert/ponytail203k4,904 new stars in the last 7 days
GAgarrytan/gstack143k598 new stars in the last 7 days
ADaddyosmani/agent-skills122k1,667 new stars in the last 7 days
Harden code against the OWASP Top 10: input handling, authentication, sessions and dependencies.
ADaddyosmani/agent-skills122k1,667 new stars in the last 7 days
RUruvnet/RuView106k739 new stars in the last 7 days