Skip to content

Latest commit

 

History

History
65 lines (44 loc) · 3.17 KB

File metadata and controls

65 lines (44 loc) · 3.17 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

Craft CMS 5.x plugin development scaffold using DDEV for the local runtime. The plugin source lives at the repo root; a full Craft CMS installation lives in craft-install/ and loads the plugin via a Composer path repository (symlink).

Architecture

  • src/ — Plugin source code. PSR-4 namespace viget\ddev\ maps here. Entry point is src/Plugin.php (extends craft\base\Plugin).
  • composer.json (root) — Defines the plugin package (viget/ddev-plugin, type craft-plugin, handle ddev-plugin).
  • craft-install/ — Full Craft CMS app. Its composer.json has a type: path repository pointing to ../, which symlinks the root plugin into craft-install/vendor/viget/ddev-plugin. Edits to src/ are reflected immediately.
  • craft (root) — PHP CLI script that bootstraps via craft-install/bootstrap.php and runs Craft's console app. Use this instead of craft-install/craft.
  • config/, storage/, tests/ — Plugin-level directories (currently empty scaffolds).

Development Commands

All commands run inside DDEV containers:

ddev start                          # Start the environment
ddev ssh                            # Shell into the web container
ddev craft <command>                # Run Craft CLI (e.g., migrate/all, project-config/apply)
ddev composer install               # Installs plugin dependencies (runs at repo root)
ddev composer install --dir craft-install  # Installs Craft app dependencies

DDEV Configuration

  • Project name: craft-viget-a11yhttps://craft-viget-a11y.ddev.site
  • Type: craftcms, docroot: craft-install/web
  • PHP 8.3, MariaDB 10.11, Nginx
  • composer_root is set to . so ddev composer operates on the plugin's root composer.json (overrides the craftcms type default of craft-install/)

Key Relationship: Root ↔ craft-install

The craft-install/composer.json requires "viget/ddev-plugin": "dev-main" and lists the repo root (../) as a path repository. Composer installs it as a symlink, so craft-install/vendor/viget/ddev-plugin → repo root. This means:

  • Plugin code changes in src/ are live immediately
  • Root composer.json defines the plugin metadata (name, handle, autoload, dependencies)
  • craft-install/composer.json defines the Craft app dependencies

Browser Automation

When asked to verify your work, use agent-browser for web automation. Run agent-browser --help for all commands.

Core workflow:

  1. agent-browser open <url> - Navigate to page
  2. agent-browser snapshot -i - Get interactive elements with refs (@e1, @e2)
  3. agent-browser click @e1 / fill @e2 "text" - Interact using refs
  4. Re-snapshot after page changes

Craft Frontend

  1. agent-browser open https://craft-viget-a11y.ddev.site

Craft Admin Workflow

  1. agent-browser open https://craft-viget-a11y.ddev.site/admin
  2. Use the following credentials for login.
    • Username: admin
    • Password: password
  3. You can also navigate to https://craft-viget-a11y.ddev.site/admin/entries/entries to view a list of entries in different states.