Code Editor
The Code Editor provides a built-in environment for editing Shopify theme files with AI assistance. Make changes directly within PeerScripts without switching contexts.
Code Editor
The Code Editor provides a built-in environment for editing Shopify theme files with AI assistance. Make changes directly within PeerScripts without switching contexts.
Overview
When Theme Intelligence detects issues, you often need to fix them in code. The Code Editor provides:
- Direct Theme Access: Browse and edit all theme files
- Syntax Highlighting: Support for Liquid, JS, CSS, and JSON
- AI Assistance: Get help understanding and fixing code
- Issue Integration: Jump directly to problematic code
- Safe Editing: Protection for live themes
Getting Started
Accessing the Code Editor
- Navigate to Code in the sidebar
- Select a theme to edit
- Browse the file tree
- Click any file to open
Theme Selection
┌─────────────────────────────────────────────────────────────────┐
│ SELECT THEME │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ 🔒 Dawn (Live) │ │
│ │ Status: Published • Cannot edit directly │ │
│ │ [Create Copy] │ │
│ ├─────────────────────────────────────────────────────────┤ │
│ │ ✏️ Development Theme │ │
│ │ Status: Unpublished • Ready to edit │ │
│ │ [Open] │ │
│ ├─────────────────────────────────────────────────────────┤ │
│ │ ✏️ Feature Branch Theme │ │
│ │ Status: Unpublished • Ready to edit │ │
│ │ [Open] │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ ⓘ Live themes are protected. Create a copy to make changes. │
└─────────────────────────────────────────────────────────────────┘
Important: The live theme is protected from direct editing. Create a copy or edit an unpublished theme.
Editor Interface
Layout Overview
┌─────────────────────────────────────────────────────────────────────────┐
│ CODE EDITOR [Theme: Development] │
├─────────────────────────────────────────────────────────────────────────┤
│ ┌──────────────┐ ┌────────────────────────────────────────────────┐ │
│ │ FILE TREE │ │ sections/header.liquid │ │
│ │ │ ├────────────────────────────────────────────────┤ │
│ │ > assets │ │ 1 │ {% comment %} │ │
│ │ > config │ │ 2 │ Header section with navigation │ │
│ │ > layout │ │ 3 │ {% endcomment %} │ │
│ │ > locales │ │ 4 │ │ │
│ │ v sections │ │ 5 │ <header class="header"> │ │
│ │ header.liq │ │ 6 │ <div class="header__inner"> │ │
│ │ footer.liq │ │ 7 │ {% render 'logo' %} │ │
│ │ ... │ │ 8 │ {% render 'navigation' %} │ │
│ │ > snippets │ │ 9 │ </div> │ │
│ │ > templates │ │ 10 │ </header> │ │
│ │ │ │ │ │ │
│ │ │ │ │ │ │
│ │ │ │ │ │ │
│ │ │ ├────────────────────────────────────────────────┤ │
│ │ │ │ AI CHAT [Ask AI] │ │
│ │ │ │ Ask questions about this code... │ │
│ └──────────────┘ └────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘
File Tree Navigation
- Click folder to expand/collapse
- Click file to open in editor
- Right-click for context menu
- Search to find files by name
Editor Features
| Feature | Description |
|---|---|
| Line numbers | Click to set breakpoints |
| Syntax highlighting | Language-aware coloring |
| Issue markers | Inline warnings from Theme Intelligence |
| Auto-complete | Suggestions for Liquid tags |
| Search & replace | Find text within file |
| Multiple tabs | Open several files |
Editing Files
Making Changes
- Open a file from the file tree
- Click in the editor to position cursor
- Make your changes
- Changes auto-save (or click Save)
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Cmd/Ctrl + S |
Save file |
Cmd/Ctrl + F |
Find in file |
Cmd/Ctrl + H |
Find and replace |
Cmd/Ctrl + G |
Go to line |
Cmd/Ctrl + / |
Toggle comment |
Cmd/Ctrl + Z |
Undo |
Cmd/Ctrl + Shift + Z |
Redo |
File Operations
| Operation | How |
|---|---|
| Create file | Right-click folder → New File |
| Rename file | Right-click file → Rename |
| Delete file | Right-click file → Delete |
| Duplicate file | Right-click file → Duplicate |
| Upload file | Drag and drop to file tree |
AI Assistance
Asking Questions
Get help understanding or fixing code:
- Select code (optional)
- Click Ask AI or press
Cmd/Ctrl + Shift + A - Type your question
- Review the AI response
Example Questions
| Question | Use Case |
|---|---|
| "What does this code do?" | Understand unfamiliar code |
| "Why might this cause a performance issue?" | Diagnose problems |
| "How can I fix this XSS vulnerability?" | Security fixes |
| "Rewrite this to use modern Liquid syntax" | Code updates |
| "Add proper accessibility attributes" | Accessibility fixes |
AI Chat Interface
┌─────────────────────────────────────────────────────────────────┐
│ AI CHAT │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ You: What does this for loop do? │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ AI: This for loop iterates through the product's │ │
│ │ variants and creates a dropdown option for each one. │ │
│ │ The `variant.title` displays the variant name, and │ │
│ │ `variant.id` is used as the option value for the │ │
│ │ cart form submission. │ │
│ │ │ │
│ │ However, I notice this loop doesn't handle the case │ │
│ │ where a variant is sold out. You might want to add: │ │
│ │ │ │
│ │ {% if variant.available %} │ │
│ │ ... │ │
│ │ {% endif %} │ │
│ │ │ │
│ │ [Apply Suggestion] │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Ask a question... [Send] │ │
│ └─────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
Applying Suggestions
When AI provides code suggestions:
- Review the suggested code
- Click Apply Suggestion
- Code is inserted at cursor (or replaces selection)
- Review and adjust as needed
Issue Integration
Viewing Issues in Editor
Theme Intelligence issues appear as inline markers:
┌─────────────────────────────────────────────────────────────────┐
│ 45 │ <div class="product-description"> │
│ 46 │ {{ product.description }} │
│ 47 │ {{ customer_note }} ⚠ [XSS: Unescaped input] │
│ 48 │ </div> │
└─────────────────────────────────────────────────────────────────┘
Jumping to Issues
From Theme Intelligence:
- View an issue
- Click View in Code Editor
- Editor opens with file and line highlighted
Issue Panel
View all issues in current file:
┌─────────────────────────────────────────────────────────────────┐
│ ISSUES IN FILE: header.liquid │
│ │
│ ⚠ Line 47: Unescaped user input (Security) │
│ ⓘ Line 89: Deprecated filter 'json' (Deprecated) │
│ ⓘ Line 123: Missing alt attribute (Best Practice) │
│ │
│ Click an issue to jump to that line │
└─────────────────────────────────────────────────────────────────┘
Asset Preview
Viewing Assets
Preview image and other assets directly:
- Navigate to the
assetsfolder - Click an image file
- Preview displays in the editor area
Supported Previews
| File Type | Preview |
|---|---|
| Images (PNG, JPG, SVG, WebP) | Visual preview |
| CSS | Syntax highlighted code |
| JavaScript | Syntax highlighted code |
| JSON | Formatted JSON view |
| Fonts | Font information |
Working with Changes
Change Tracking
The editor tracks your modifications:
┌─────────────────────────────────────────────────────────────────┐
│ CHANGES │
│ │
│ Modified Files: │
│ ├─ sections/header.liquid (3 changes) │
│ ├─ snippets/product-card.liquid (1 change) │
│ └─ assets/custom.css (5 changes) │
│ │
│ [View Diff] [Discard All] [Save All] │
└─────────────────────────────────────────────────────────────────┘
Viewing Diffs
See what changed:
- Click View Diff on a file
- Side-by-side comparison shows
- Additions in green, deletions in red
Discarding Changes
Revert to the last saved version:
- Single file: Right-click → Discard Changes
- All files: Click Discard All in Changes panel
Theme Safety
Live Theme Protection
The live theme cannot be edited directly:
- Prevents accidental production changes
- Forces use of development workflow
- Creates audit trail
Creating a Safe Copy
To edit live theme code:
- Select the live theme
- Click Create Copy
- Name the copy (e.g., "Development")
- Edit the copy
- When ready, publish the copy to make it live
Best Practices
- Always edit copies - Never edit live themes
- Test before publishing - Preview changes thoroughly
- Use version control - Export themes regularly
- Document changes - Add comments to explain modifications
File Upload
Uploading Assets
Add new files to themes:
- Navigate to target folder
- Drag and drop files, or click Upload
- Files are added to theme
Supported Uploads
- Images (PNG, JPG, GIF, SVG, WebP)
- Fonts (WOFF, WOFF2, TTF)
- CSS and JavaScript
- Liquid templates
Search Across Files
Global Search
Search all files in the theme:
- Press
Cmd/Ctrl + Shift + F - Enter search term
- View results across all files
- Click result to open file
Search Options
| Option | Description |
|---|---|
| Case sensitive | Match exact case |
| Regex | Use regular expressions |
| File types | Limit to specific extensions |
Best Practices
Code Quality
- Follow Shopify standards - Use documented patterns
- Comment your code - Explain complex logic
- Use snippets - Reusable code components
- Keep files organized - Logical folder structure
Performance
- Minimize JavaScript - Only load what's needed
- Optimize images - Compress before upload
- Use lazy loading - Defer off-screen content
- Avoid inline styles - Use CSS files
Security
- Escape output - Always use
| escapefor user input - Validate input - Check data before using
- Use HTTPS - For all external resources
- Review dependencies - Keep libraries updated
Troubleshooting
File Won't Save
- Check theme permissions
- Verify file isn't too large
- Check network connection
- Try refreshing the page
AI Not Responding
- Check internet connection
- Try a simpler question
- Refresh the chat panel
- Check AI settings in Settings
Syntax Highlighting Wrong
- Verify file extension is correct
- Try closing and reopening file
- Check for unusual characters
Related Features
- Theme Intelligence - Code analysis
- Changes Tracking - Monitor modifications
- Tickets - Track code fixes