From cfdd15c771f277fa0cf36541c9875569a7dfafce Mon Sep 17 00:00:00 2001 From: Carlos Date: Sun, 19 Apr 2026 18:50:51 +0200 Subject: [PATCH 1/3] docs: extract cross-app patterns into skill v1.9 and AGENTS.md Ports rules 26-29 back into the canonical YAML source (they had drifted into the generated SKILL.md only) and adds rules 30-36 capturing generic patterns observed across multiple downstream apps: public env bridge, router UX defaults, Link wrapper preserving search, public-route allowlist, Sentry user+feedback binding, single markdown artifact for help/AI/prompts, and distinct-value filter discovery tools. AGENTS.md gains inline amendments (hydration-safe color scheme, satisfies over as, pre-auth redirect middleware, loaderDeps cache keying, virtual-field explainer, fluent prompt builder, Zod round-trip factories, dual Playwright webServer) and new top-level sections for Public Runtime Config, Bulk Edit Pattern, Override/Overlay Repository Pattern, Sortable Tables, and Autosave Forms with concurrency guards. Made-with: Cursor --- .../tanstack-fullstack-pattern/SKILL.md | 11 ++ AGENTS.md | 142 +++++++++++++++++- skills/dist/tanstack-fullstack-pattern.md | 15 +- skills/registry.json | 22 ++- .../src/tanstack-fullstack-pattern.skill.yaml | 82 ++++++++-- 5 files changed, 251 insertions(+), 21 deletions(-) diff --git a/.agents/skills/tanstack-fullstack-pattern/SKILL.md b/.agents/skills/tanstack-fullstack-pattern/SKILL.md index 7586b43..12ef857 100644 --- a/.agents/skills/tanstack-fullstack-pattern/SKILL.md +++ b/.agents/skills/tanstack-fullstack-pattern/SKILL.md @@ -47,6 +47,17 @@ An interface-first fullstack architecture built on TanStack Start. The pattern d 23. Latest dependencies: install and keep dependencies at latest compatible versions. Never pin exact versions unless a known incompatibility exists. Use `pnpm add ` (no version suffix); run `pnpm outdated` and `pnpm update` to align the lockfile. 24. Ask for LLM provider: when scaffolding a new project or when the user's LLM preference is unclear, ask which provider they want before writing the adapter. Install only the chosen `@tanstack/ai-*` adapter package and configure matching env vars. Default is `@tanstack/ai-openai`; do not assume OpenAI without asking. See AGENTS.md section 8 for the full provider table. 25. Generate the system prompt: when scaffolding a new app, ask the user about their domain — entities, capabilities, and permissions — then generate a tailored `BASE_SYSTEM_PROMPT` in `src/routes/api/chat.ts` with six sections (Capabilities, Data Model, Links and navigation, Mutations and data refresh, Permissions and errors, Guidelines). Do not reuse the template's task-management prompt. `buildSystemPrompt()` composes this base with dynamic context (rule 14) and the navigation manifest. `chat()` from `@tanstack/ai` receives it via `systemPrompts: string[]`. See AGENTS.md section 8 "System Prompt Generation" for the full template. +26. Repository-resolved authorization: `authMiddleware` extracts JWT claims **and** calls a repository method (e.g. `getReadRepository().getUserAccess(email)`) to enrich `AuthContext` with application-defined access data — roles, group memberships, owned scopes, superuser flags. Downstream guards (`requireAuth`, `requireGroup`, any app-specific `requireOwnerOf`) and AI tools read this enriched context so UI and AI see the same permission signals. Authorization checks live **inside** server-function handlers (not only in UI components), so permissions are enforced regardless of whether the caller is the UI, the AI, or a direct HTTP client. +27. Write attribution via traceability context: `WritableRepository` methods accept an optional `TraceabilityContext` (`createdBy`, `createdDate`, `lastModifiedBy`, `lastModifiedDate`) built from the authenticated identity. Mutation server-function handlers construct it from `ctx.context.user.email` (available after `requireAuthMiddleware`) and pass it to the repository. Seed and production implementations apply it consistently. This gives UI and AI callers the same audit trail without duplicating logic at each call site. +28. JSON-only server functions and tools; HTTP file routes for everything else: `createServerFn` (and therefore AI tools) handles JSON queries and mutations only. Non-JSON responses — file downloads (CSV/JSON exports, PDFs), uploads, webhooks, and streaming — go through TanStack Start HTTP file routes using `server.handlers.GET|POST` under `src/routes/api/*.ts`. The `/api/chat` SSE endpoint (rule 14) is the canonical example. These file routes still reuse server-function wrappers or repository methods internally so the data path stays unified, but the transport layer is explicit about its shape. +29. Explicit agent loop depth: configure `agentLoopStrategy: maxIterations(N)` explicitly on the `chat()` call (default N=10). This caps the number of consecutive tool-calling iterations the AI can run before returning a final answer, which bounds latency, cost, and infinite-loop risk. Tune N only after measuring; do not rely on the framework default. +30. Public runtime config bridge: expose non-secret runtime config (Sentry DSN, environment name, feature flags) via a GET server function `getPublicEnv()` and inline the result as `window.__ENV__` in the root `RootDocument` using a small `