A rule in the Context Base is an always-on constraint that agents follow on every task in your project. Image loading patterns, SEO coverage, i18n for user-facing strings, architectural guardrails, “never do X without asking” policies — anything that should apply uniformly regardless of what the agent is being asked to do. Rules are the boring infrastructure of consistency. They’re not exciting, but they’re the difference between a codebase where the same pattern is used the same way everywhere and one where every developer (human or AI) reinvents it.Documentation Index
Fetch the complete documentation index at: https://docs.frontic.com/llms.txt
Use this file to discover all available pages before exploring further.
Project Rules vs. Context Rules
Frontic exposes rules on two surfaces, and most projects use both:- Project Rules — a single, monolithic document in Studio Settings → Project Rules. Always applied in full, not modular, not targeted. Good for the short list of constraints that must absolutely hold on every task regardless of what else is going on: “product images always through the CDN”, “no rounded corners on the brand”, “every user-facing string gets a translation key”.
- Context Rules — individual rule files in the Context Base, each focused on one concern. Modular: review, update, and delete them independently. The rest of this page is about Context Rules — they’re what you edit in Studio → Context → Rules and what grows with your project over time.
How rules fit with the other Context Base types
Quick reminder on how the four types divide the work:- Rules apply on every task by default — constraints that hold uniformly, narrowable by path when a rule should only fire in certain parts of the codebase.
- Skills apply when the task touches the domain (or when you force them by name) — domain experts like
seo-optimizerkick in whenever relevant. - Commands apply only when you force them by name — task procedures like
code-review, same body shape as a skill but the agent never auto-picks one. - Guides apply when explicitly referenced — reference documents the agent pulls in on demand.
What rules are good for
Performance defaults
“Load product images through the CDN with responsive
srcset, not
from the source URL.” “Lazy-load below-the-fold blocks.” “Never
fetch Frontic data in client components — use the server layer.”
Things that must hold on every page or revenue suffers.SEO coverage
“Every page gets a canonical URL and the built-in SEO composite.”
“Withdrawn categories 302-redirect, never 404.” “Locale variants
link each other via hreflang.” The SEO basics agents forget to
include unless told.
i18n coverage
“Every user-facing string gets a translation key — no hardcoded
copy.” “New translatable fields need entries for every active
locale before merging.” The rules that keep the multi-market build
shippable.
Accessibility baselines
“Every interactive element needs an accessible name.” “Maintain
WCAG AA contrast on brand colors.” “Every new form field gets a
visible label.” Non-negotiable floors agents can’t be trusted to
apply without a rule.
Architectural discipline
“Never drop a field from a storage schema — deprecate it first.”
“Never edit a generated client file by hand.” “Always render
through a server component, never fetch in the browser.” Boundaries
that prevent slow, expensive mistakes.
Architectural guardrails
“All listings go through the generated SDK, never raw fetch.” “Use
Frontic UI components before building new ones.” “Block components
live under
components/blocks/, not mixed into pages.” Patterns
you want everywhere without nagging.Writing a rule
Open Studio → Context → Rules in the admin app and click New Rule. Creation asks for two things:- Name — short, memorable.
product-images-through-cdnis good;miscellaneous-frontend-rulesis not. - Description — one sentence summarising the constraint, shown in the rules list.
product-images-through-cdn should be its own rule, not buried inside a 50-line “general frontend rules” document. Focused rules are easier to review, easier to update, and easier to delete when they become obsolete.
Keep the total count small, too. Agents already apply sensible defaults for the obvious things — “make layouts responsive”, “handle errors gracefully”, “write accessible markup”. Rules earn their place by enforcing the specific decisions your project made that the agent wouldn’t guess — a brand constraint like “no rounded corners”, a commerce choice like “product images only through the CDN”, a destructive-action boundary unique to your setup. If a rule restates what a competent engineer would already do, it adds noise on every task without moving the output.
Example: Product images through the CDN
<FronticImage> component gets used, CDN URLs get generated, raw source URLs get flagged. If you see a stray <img src="{record.image.url}"> proposed, the rule isn’t being read; check that it’s Active.
Example: Use createClient for SDK initialization
Rules are project-wide
Rules apply on every build-side agent task in the project — whether the agent is running in a Studio workspace or your editor — scoped to whatever paths targeting allows. Rules don’t govern Buddy; Buddy has its own separate context and can read or edit rule documents without applying them to its own behavior. If you have a guideline that only applies in one situation, that’s a sign it should probably be a skill scoped to that situation, not a rule.Targeting a rule by path
By default, every Context Rule applies to every build-side task. When a rule should only fire when the agent is touching certain parts of the codebase, narrow it using the Apply to field on the rule’s metadata. Open a rule in Studio → Context → Rules and find Apply to alongside name and description. Add one or more path patterns — for examplesrc/checkout/** or src/api/payments/**. The rule will apply only when a task touches a matching path; leave Apply to empty and the rule applies everywhere.


Reviewing and pruning rules
Rules decay. A rule that was essential six months ago might be obsolete because the codebase moved, the framework changed, or the convention it enforced is now the default. When something feels off — a rule that keeps getting violated, a new pattern that supersedes an old one, a teammate flagging friction — walk through the list and ask:- Is this still true? If the codebase no longer follows it, decide: update the rule, or delete it.
- Does this still matter? A rule that’s technically correct but irrelevant to the work people are actively doing is noise.
- Is this still the right granularity? Rules that accumulated into multi-concern walls of text should be split.
Rules agents can’t follow perfectly
Rules aren’t executable code — the agent reads them and tries. That means some rules are imperfectly enforced:- Vague rules get vague compliance. A rule that says “write clean code” is meaningless. A rule that says “prefer early returns over nested conditionals” is actionable.
- Contradictory rules produce arbitrary behavior. If Rule A says “always use arrow functions” and Rule B says “always export named functions”, the agent picks one. Review your rules for contradictions when you add new ones.
- Rules that require information the agent doesn’t have get skipped. If a rule says “always tag blocks with the owner team”, the agent needs to know what the owner team is. Put the information in the rule or the agent can’t apply it.
Related
Context Base
The mental model for the whole Context Base.
Skills
Task-specific reusable know-how.
Commands
Named shortcuts for recurring operations.
Guides
Reference documents the agent reads on demand.