Skip to main content
rule

shopify-theme-dev-liquid — Cursor rule for Shopify theme development

A Cursor rule collecting Shopify theme practices across Liquid, JavaScript, CSS, accessibility and performance. Useful when you build a theme and want the agent to keep the structure.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/shopify-theme-dev-liquid.mdc
Open on GitHub

What shopify-theme-dev-liquid does

The file sets standards for Shopify theme files. It covers project structure, Liquid templating, JavaScript, CSS/SCSS, sections and blocks, performance, accessibility, maintenance and testing. On the Liquid side it suggests the render tag over include, keeping database queries out of loops, and moving intricate logic into JavaScript. For JS it asks for ES modules, const/let, and event delegation instead of direct DOM work. For styles it points at BEM, OOCSS or Utility-First, plus CSS variables for colors and fonts.

The rule attaches through globs: **/*.liquid, assets/**/*.js, assets/**/*.css, sections/**/*.liquid, snippets/**/*.liquid, templates/**/*.liquid. It only fires on those files, not across the whole project, so it is worth checking that your theme path matches the pattern. Installing it means dropping .cursor/rules/shopify-theme-dev-liquid.mdc into the repo.

A few items that are easy to miss: sections should not hardcode content, they should expose Schema settings instead; images go through Shopify's CDN with the image_url filter; and for quality checks the rule names Shopify Theme Check and Google Lighthouse.

What it helps with

  • lay out theme files into sections, snippets, templates and assets
  • swap include for render in Liquid templates
  • keep database queries out of Liquid loops
  • move intricate logic from Liquid into JavaScript
  • set up Schema and presets for sections instead of hardcoding content

Example prompts for the agent

  • Check my Shopify theme against the shopify-theme-dev-liquid rule and flag broken directory structure
  • Rewrite this Liquid template: drop include, use render, and move the logic into JS
  • Run this section through the accessibility checklist from the rule: alt text, focus states, ARIA

How to install shopify-theme-dev-liquid

Manually: put the files in place

.cursor/rules/shopify-theme-dev-liquid.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about shopify-theme-dev-liquid

How do I install shopify-theme-dev-liquid in Cursor?

Create .cursor/rules/shopify-theme-dev-liquid.mdc in your project root and paste the rule content into it. Cursor picks it up automatically for files matching the globs.

What does shopify-theme-dev-liquid do?

It lays out practices for Shopify theme development: directory structure, Liquid tags, modular JavaScript, CSS organization, sections and blocks, performance, accessibility and testing.

Which files does this rule apply to?

**/*.liquid, assets/**/*.js, assets/**/*.css, sections/**/*.liquid, snippets/**/*.liquid and templates/**/*.liquid. If your theme lives elsewhere, the rule will not fire.

Source text

shopify-theme-dev-liquid.mdc · CC0-1.0
---
description: "Best practices for Shopify theme development with Liquid, JavaScript, and CSS"
globs: ["**/*.liquid", "assets/**/*.js", "assets/**/*.css", "sections/**/*.liquid", "snippets/**/*.liquid", "templates/**/*.liquid"]
alwaysApply: false
---
# Shopify Theme Development Best Practices

## Project Structure
- Adopt a clear **directory structure**, e.g., `sections`, `snippets`, `templates`, `assets`.
- Organize **generic modules** (like JavaScript functionalities) into separate files.
- Keep **Liquid files** concise and focused on single responsibilities, avoiding monolithic files.
- Organize templates and sections by **page or functionality**.
- Implement proper **internationalization (i18n)** file management.
- Utilize **SCSS/CSS Modules** for style organization to prevent global pollution.

## Liquid Templating
- Prefer the `render` tag over `include`.
- Limit **database queries** within loops to avoid N+1 issues.
- Use **filters** judiciously, especially complex computational ones.
- Leverage Liquid's **caching mechanisms** to reduce redundant calculations.
- Avoid complex **logic handling** directly in Liquid; move intricate logic to JavaScript.
- Use `assign` and `capture` to define and reuse variables effectively.

## JavaScript Development
- Modularize JS, using **ES Modules** for imports and exports.
- Follow modern JavaScript **best practices**, such as `const`/`let`, arrow functions, etc.
- Avoid direct **DOM manipulation**; prioritize event delegation.
- Optimize **JavaScript performance** to reduce repaints and reflows.
- Consider using **Webpack/Rollup** for bundling and code optimization.
- Write clear **comments** and **JSDoc**.

## CSS/SCSS Styling
- Adhere to naming conventions like **BEM, OOCSS, or Utility-First CSS**.
- Optimize **CSS selectors** to improve rendering performance.
- Use **CSS variables** to manage theme configurations like colors and fonts.
- Implement **responsive design** to ensure consistent theme appearance across devices.
- Minimize **CSS file size** by removing unused styles.
- Make good use of **SCSS mixins** and **functions**.

## Sections and Blocks
- Utilize Section **Schema** to define configurable options.
- Maintain **section independence and reusability**.
- Provide clear **presets** for sections.
- Use **Blocks** appropriately to enhance section flexibility.
- Ensure sections provide a good user experience in the **Shopify Customizer**.
- Avoid hardcoding content within sections; use Schema configurations whenever possible.

## Performance Optimization
- Optimize **image loading** by using Shopify's CDN and the `image_url` filter.
- Minify **JavaScript and CSS files**.
- Leverage **browser caching**.
- Reduce the number of **HTTP requests**.
- Consider **lazy loading**.
- Monitor **theme performance** using Google Lighthouse and Shopify Theme Check.

## Accessibility (A11y)
- Ensure all interactive elements are **keyboard accessible**.
- Provide meaningful **`alt` text** for images.
- Use correct **HTML semantic tags**.
- Consider **color contrast**.
- Implement clear **focus states**.
- Use **ARIA attributes** to enhance the accessibility of complex components.

## Maintenance and Scalability
- Write clear **code comments** and documentation.
- Follow **naming conventions** to maintain code consistency.
- Regularly **test** theme functionalities.
- Ensure compatibility across different **browsers and devices**.
- Consider future **extensibility**, avoiding tight coupling.
- Use **Shopify CLI** for local development and deployment.

## Quality and Testing
- Use **Shopify Theme Check** for static code analysis.
- Write **unit tests** (where applicable).
- Conduct thorough **end-to-end testing**.
- Test in various environments (local, development store, production store).
- Focus on **compatibility testing** (browsers, devices, Shopify versions).
- Test **error handling** and edge cases.

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set68

svelte A Cursor rule that steers the agent toward Svelte conventions: component structure, reactivity, stores, SvelteKit routing and tests. Useful when the agent writes or edits Svelte code. ★ 41,011repo stars solidjs-tailwind-cursorrules-prompt-file A Cursor rule that tells the agent how to write Solid.js code with Tailwind CSS: signals, utility classes, folder layout. ★ 41,011repo stars solidity-hardhat-cursorrules-prompt-file A Cursor rule that turns the AI assistant into a Solidity and smart contract security expert, with Hardhat-based testing and gas work. ★ 41,011repo stars snowflake-snowpark-dbt-cursorrules-prompt-file A Cursor rule that gives the agent context for Snowpark Python and dbt with the Snowflake adapter. Useful when you write transformation pipelines in either tool. ★ 41,011repo stars salesforce-apex-cursorrules-prompt-file A Cursor rule that points the agent at Salesforce Apex work: queueables instead of @future, GoF patterns, and almost no comments. ★ 41,011repo stars rtl-right-to-left-i18n-cursorrules-prompt-file A Cursor rule that pushes the agent toward logical CSS and Tailwind utilities instead of left/right. Useful when the app has to run in Arabic, Hebrew, Persian or Urdu. ★ 41,011repo stars react This rule hands Cursor a set of React conventions: component structure, hooks, state, forms and accessibility. Useful when a project has plenty of .tsx and .jsx and you want one style. ★ 41,011repo stars react-typescript-nextjs-nodejs-cursorrules-prompt- A Cursor rule that pins down React, TypeScript, Next.js 14 and Node.js conventions: functional components, RORO, minimal use client. ★ 41,011repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor