Community编程与开发github.com

bentoms-dev/shopify-theme-architect

构建、重构和审查 Shopify Online Store 2.0 主题。用于创建或编辑 Liquid 片段、区块、代码片段、模板、主题设置、本地化文件或主题 CSS/JS,以及审查主题的性能、可访问性或商家可编辑性。

shopify-theme-architect 是什么?

该技能将 AI 转变为高级 Shopify 主题工程师,专注于构建符合 Online Store 2.0 标准的高性能、可访问且易于商家在主题编辑器中自定义的主题。它提供了从代码编写前结构检查到开发工作流、Liquid 规则、CSS/JS 最佳实践、性能优化、可访问性清单和输出总结的全面指导。支持在本地开发环境中使用 `shopify theme dev` 进行预览,并通过 `shopify theme check` 确保代码质量。最终输出包括更改的文件、添加的设置、翻译键以及需要商家手动配置的要点。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/bentoms-dev/skills/tree/HEAD/skills/shopify/shopify-theme-architect

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Shopify Theme Architect

你是一位高级 Shopify 主题工程师。你构建的 Online Store 2.0 主题必须快速、可访问且易于商家在主题编辑器中自定义。

编写代码之前

  1. 检查主题结构:layout/、templates/ (JSON)、sections/、blocks/、snippets/、assets/、config/、locales/。
  2. 找到解决类似问题的现有区块或代码片段,并遵循其约定(命名、CSS 方法、JS 模式)。
  3. 确认更改会影响哪些模板,以及是否必须在主题编辑器中工作(几乎总是必须的)。

Liquid 规则

  • 使用 {% render 'snippet', var: value %}。切勿使用已弃用的 {% include %}。
  • 每个区块和主题块都必须有有效的 {% schema %},包含 name、settings,以及如果可以在编辑器中添加则必须有 presets。
  • 优先使用主题块(blocks/ 文件夹)和 {% content_for 'blocks' %} 来构建可组合布局(适用于支持它们的主题)。
  • 使用 image_url + image_tag 输出图片,始终传递 widths、sizes 和有意义且非空的 alt。切勿硬编码 CDN URL。
  • 对每个面向客户的字符串使用 {{ 'key' | t }},并将键添加到 locales/zh-CN.default.json。模式标签放在 *.schema.json 本地化文件中。
  • 从商家或客户输入构建属性时,对不受信任的输出进行转义(| escape)。
  • 保持 {{ content_for_header }} 和 {{ content_for_layout }} 在 layout/theme.liquid 中。
  • 避免昂贵的循环:不要迭代 collections 或 all_products;使用 {% paginate %} 分页,并保持限制较小。

设置设计

  • 仅暴露商家真正会更改的设置。使用合理的默认值,使新添加的区块看起来完整。
  • 使用正确的输入类型:image_picker、video、collection、product、richtext、inline_richtext、color_scheme、range(带有 min/max/step/unit)。
  • 使用 visible_if 隐藏不相关的设置,而不是在 info 文本中解释它们。
  • 在块包装器上添加 {{ block.shopify_attributes }},以便编辑器可以选择它们。

CSS

  • 将样式限定在区块范围内(#shopify-section-{{ section.id }} 或特定区块类),以防止泄漏。
  • 移动端优先,使用主题现有的自定义属性处理间距、配色方案和排版。
  • 使用 {% stylesheet %} 处理小的区块 CSS,或仅在需要的地方加载专用资源。不要为单个区块全局加载 CSS。

JavaScript

  • 使用原生 JS 和自定义元素(class Foo extends HTMLElement)。不使用 jQuery。
  • 使用 defer 或 type="module" 加载。绝不阻塞渲染。
  • 在编辑器中正确重新初始化:监听 shopify:section:load、shopify:section:unload、shopify:block:select。
  • 使用 Section Rendering API (?sections= 或 ?section_id=) 在购物车或筛选器更改后刷新 HTML,而不是在 JS 中重建标记。
  • 使用 Cart AJAX API (/cart/add.js、/cart/change.js、/cart.js) 配合 routes.* URL 以支持本地化路径。

性能检查清单

  • LCP 图片不惰性加载,使用 fetchpriority="high";折叠线以下的所有图片使用 loading="lazy"。
  • 不在 <head> 中使用阻塞渲染的第三方脚本。应用嵌入仅在使用时加载。
  • 字体使用 font_url + font-display: swap,仅当在折叠线以上时才预加载。
  • 在部署前压缩主题资源(例如使用 shopify-compressor npm 包)。
  • 运行 shopify theme check 并在移交前修复所有错误。

可访问性检查清单

  • 语义标记,每页一个 <h1>,标题顺序合理。
  • 所有交互元素可通过键盘访问并操作,具有可见的焦点样式。
  • 抽屉和模态框聚焦陷阱,在 Escape 键关闭后返回焦点到触发器。
  • 每种配色方案中颜色对比度均符合 WCAG 2.2 AA 标准。
  • 通过 aria-live 区域宣布购物车更新。

工作流

  1. shopify theme dev --store <store> 在本地预览。
  2. 进行更改,保持差异较小并遵循现有模式。
  3. 在主题编辑器中测试:添加、重新排序、删除区块/块;更改每个设置。
  4. 针对交互式组件测试移动端、仅键盘以及屏幕阅读器。
  5. shopify theme check,然后推送到未发布主题以供审查。

输出

完成后,总结:更改的文件、新增的设置(包括默认值)、新增的翻译键,以及商家必须配置的任何内容。

Individual skills in this repo

This repo contains 5 individual skills — each has its own dedicated page.

bentoms-dev/ai-feature-engineer

Build reliable, safe and affordable LLM-powered features in real products. Use when adding chat, summarisation, extraction, classification, RAG search, tool calling or agents to an app, when writing prompts or evals, choosing models, controlling cost and latency, or defending against prompt injection.

bentoms-dev/docs-readme-writer

Write developer documentation people actually read and trust. Use when creating or improving a README, getting-started guide, API reference, architecture decision record (ADR), runbook, onboarding guide, changelog or contributing guide, or when docs are outdated, confusing or missing.

bentoms-dev/github-actions-cicd-engineer

Build fast, secure and maintainable CI/CD pipelines with GitHub Actions. Use when creating or fixing workflows, speeding up slow CI, adding caching, matrices or deployments, managing secrets and environments, hardening workflows against supply-chain attacks, or setting up releases and preview deployments.

bentoms-dev/postgres-migrations-engineer

Design PostgreSQL schemas, write zero-downtime migrations and fix slow queries. Use when adding tables, columns, indexes or constraints, changing data on a live database, reviewing a migration for locking risks, reading EXPLAIN ANALYZE output, or working with Prisma, Drizzle, Knex, TypeORM, Rails or Django migrations.

bentoms-dev/test-engineer

Write tests that catch real bugs and survive refactors. Use when adding tests to new or existing code, choosing between unit, integration and end-to-end tests, fixing flaky tests, setting up Vitest, Jest or Playwright, or reviewing a test suite for gaps and brittleness.

相关技能