Globales Ranking · von 601 Skills
craft cms skills AI Agent Skill
Quellcode ansehen: happycog/craft-skill
CriticalInstallation
npx skills add happycog/craft-skill --skill craft cms skills 5
Installationen
Craft Skill
A standalone CLI tool that provides programmatic access to Craft CMS content management capabilities. Designed specifically for AI agents and automation workflows.
Overview
Craft Skill is distributed as a self-contained PHAR executable (PHP Archive) that bootstraps your Craft CMS installation and exposes all CMS functionality through a clean command-line interface.
One file. No dependencies. Just point it at your Craft installation.
Claude Skills Integration
This tool is structured as a Claude Skill - a specialized capability that can be connected to Claude (Anthropic's AI assistant) to enable it to interact with your Craft CMS installation directly via CLI commands.
By adding this skill to Claude, you transform your Craft CMS site into an AI-accessible content management system, enabling natural language content operations and automated CMS administration tasks.
Features
- Entry Management: Create, read, update, and delete entries with full field support
- Content Search: Search across entries with flexible query capabilities
- Section Management: Create and configure sections with different types (single, channel, structure)
- Entry Type Management: Define and manage entry types with custom field layouts
- Field Management: Create and configure custom fields with support for multiple field types
- Field Layout Management: Build and modify field layouts programmatically
- Draft Support: Create, update, and apply drafts for content workflows
- Asset Management: Upload, update, and manage assets and volumes
- Address Management: Create, read, update, and delete owner-backed addresses plus manage the global address field layout
- User Management: Create, read, update, and delete users plus inspect the global user field layout
- User Group Management: Manage user groups and permissions on Craft Pro installations
- Site Information: Access multi-site configuration details
- Commerce: Products: Create, read, update, and delete products with variant support
- Commerce: Variants: Manage product variants with pricing, inventory, and dimensions
- Commerce: Orders: Search and manage orders with status updates
- Commerce: Stores: View and configure store settings, checkout behavior, and pricing strategies
Installation
Quick Start
Download the PHAR and start using it immediately:
# Download the latest release
curl -LSs https://github.com/happycog/craft-skill/releases/latest/download/agent-craft.phar -o agent-craft
chmod +x agent-craft
# Use it with any Craft installation
./agent-craft --path=/path/to/craft sections/listGlobal Installation (Recommended)
Make the tool available from anywhere on your system:
# Move to system path
sudo mv agent-craft /usr/local/bin/agent-craft
# Now use from any directory
agent-craft --path=/path/to/craft sections/listVerify Installation
Test that the tool can bootstrap your Craft installation:
agent-craft --path=/path/to/craft sections/listYou should see a JSON response with your Craft sections.
Build from Source (Optional)
If you want to build the PHAR yourself:
# Clone the repository
git clone https://github.com/happycog/craft-skill.git
cd craft-skill
# Build the PHAR
php -d phar.readonly=0 bin/build-phar.php
# Use the built PHAR
./agent-craft.phar --path=/path/to/craft sections/listUsage
Basic Command Structure
agent-craft <tool/action> [positional-args] [--flags]Simple Examples
# List all sections
agent-craft sections/list
# Get a specific entry by ID
agent-craft entries/get 123
# Create an entry with simple fields
agent-craft entries/create \
--sectionId=1 \
--entryTypeId=2 \
--title="My New Entry" \
--slug="my-new-entry"
# Search entries
agent-craft entries/search --query="blog post"
# Delete an entry
agent-craft entries/delete 123Complex Examples (with structured data)
For operations requiring structured data, use query string-style bracket notation:
# Create entry with field data using bracket notation
agent-craft entries/create \
--sectionId=1 \
--entryTypeId=2 \
--title="Product Page" \
--fields[bodyContent]="<p>Description here</p>" \
--fields[relatedEntries]=45,67,89
# Arrays using comma-separated values
agent-craft entries/update 123 \
--title="Updated Title" \
--fields[categories]=5,6,7 \
--fields[customField]="value"
# Arrays using repeated flags with auto-indexing
agent-craft entries/create \
--title="Gallery" \
--fields[images][]=123 \
--fields[images][]=456 \
--fields[images][]=789
# Nested objects with bracket notation
agent-craft sections/create \
--name="Blog" \
--handle="blog" \
--type="channel" \
--siteSettings[0][siteId]=1 \
--siteSettings[0][uriFormat]="blog/{slug}" \
--siteSettings[0][template]="blog/_entry"
# For very complex nested structures, JSON strings are still supported
agent-craft entries/create \
--title="Complex Entry" \
--fields[matrix]='[{"type":"imageBlock","image":[123],"caption":"Photo"},{"type":"textBlock","text":"Content"}]'
# Mix simple flags with nested bracket notation
agent-craft entries/create \
--sectionId=1 \
--title="Article" \
--slug="my-article" \
--fields[author]="John Doe" \
--fields[tags]=news,featured,homepage \
--fields[excerpt]="Short description"Working with Different Craft Installations
The tool can work with any Craft installation using the --path flag:
# Point to a specific Craft installation
agent-craft --path=/var/www/craft sections/list
# Work with multiple installations
agent-craft --path=/var/www/site1 sections/list
agent-craft --path=/var/www/site2 sections/list
# If run from within a Craft project, --path is optional
cd /var/www/craft
agent-craft sections/list # Auto-detects current directoryVerbose Output & Debugging
Use -v, -vv, or -vvv flags for progressively more verbose output:
# Show basic error messages
agent-craft entries/create --title="Test" -v
# Show detailed error information
agent-craft entries/create --title="Test" -vv
# Show full stack traces
agent-craft entries/create --title="Test" -vvvOutput Format
All successful operations return JSON to stdout:
{
"id": 123,
"title": "My Entry",
"slug": "my-entry",
"sectionId": 1,
"url": "https://your-site.com/admin/entries/blog/123"
}Errors are written to stderr with appropriate exit codes:
0- Success1- General error2- Invalid arguments3- Craft not found or bootstrap failed
Available Tools
All tools from the HTTP API are available via CLI. Common operations include:
Entries
entries/create- Create new entryentries/get <id>- Get entry by IDentries/update <id>- Update existing entryentries/delete <id>- Delete entryentries/search- Search entries
Sections
sections/create- Create new sectionsections/list- List all sectionssections/update <id>- Update sectionsections/delete <id>- Delete section
Entry Types
entry-types/create- Create new entry typeentry-types/list- List all entry typesentry-types/update <id>- Update entry typeentry-types/delete <id>- Delete entry type
Fields
fields/create- Create new fieldfields/list- List all fieldsfields/types- List available field typesfields/update <id>- Update fieldfields/delete <id>- Delete field
Drafts
drafts/create- Create draft for entrydrafts/update <id>- Update draftdrafts/apply <id>- Apply draft to entry
Assets
assets/create- Upload new assetassets/update <id>- Update assetassets/delete <id>- Delete assetvolumes/list- List asset volumes
Addresses
addresses/list- List/search addressesaddresses/get <id>- Get address by IDaddresses/create- Create address for an owner or address fieldaddresses/update <id>- Update addressaddresses/delete <id>- Delete addressaddresses/field-layout- Get the global address field layout
Users
users/list- List/search usersusers/get <id>- Get user by IDusers/create- Create userusers/permissions- List available user permissionsusers/update <id>- Update userusers/delete <id>- Delete userusers/field-layout- Get the global user field layout
User Groups
user-groups/list- List user groupsuser-groups/get <id>- Get user group by IDuser-groups/create- Create user groupuser-groups/update <id>- Update user groupuser-groups/delete <id>- Delete user group
Other
sites/list- List all sitesfield-layouts/create- Create field layoutfield-layouts/get- Get field layoutfield-layouts/update <id>- Update field layout
Commerce: Products
products/create- Create new productproducts/get <id>- Get product by IDproducts/search- Search/filter productsproducts/update <id>- Update productproducts/delete <id>- Delete productproduct-types/list- List product typesproduct-types/get <id>- Get product type by ID with field layoutsproduct-types/create- Create product typeproduct-types/update <id>- Update product typeproduct-types/delete <id>- Delete product type
Commerce: Variants
variants/create- Create variant for a productvariants/get <id>- Get variant by IDvariants/update <id>- Update variantvariants/delete <id>- Delete variant
Commerce: Orders
orders/get <id>- Get order by IDorders/search- Search/filter ordersorders/update <id>- Update order statusorder-statuses/list- List order statuses
Commerce: Stores
stores/list- List all stores with configurationstores/get <id>- Get store by IDstores/update <id>- Update store settings
For detailed documentation on each tool, see the SKILLS documentation.
Development
Running Tests
composer install
./vendor/bin/pestStatic Analysis
./vendor/bin/phpstan analyseBuilding the PHAR
# Clone the repository
git clone https://github.com/happycog/craft-skill.git
cd craft-skill
# Build the PHAR
php -d phar.readonly=0 bin/build-phar.php
# The built PHAR will be at agent-craft.phar (under 1 MB)How It Works
The agent-craft PHAR is a self-contained CLI tool that:
- Contains all plugin source code (under 1 MB)
- Locates your Craft installation (via
--pathor current directory) - Bootstraps Craft and Yii2 frameworks from that installation
- Parses CLI arguments and maps them to tool methods
- Executes the requested operation using Craft's APIs
- Returns JSON results to stdout
No HTTP server. No Composer installation. No dependencies to manage.
The PHAR bundles only the plugin code and bootstraps against your existing Craft installation, keeping it lightweight and compatible with any Craft version.
Troubleshooting
"Craft not found" Error
Ensure you're pointing to a valid Craft installation with --path:
agent-craft --path=/var/www/craft sections/listThe tool looks for vendor/craftcms/cms in the specified path.
Permission Issues
Ensure the PHAR is executable:
chmod +x agent-craftComplex Field Data
When using bracket notation for structured data:
Query String Style (Recommended)
# Good - bracket notation is clean and readable
agent-craft entries/create --fields[bodyContent]="<p>Test</p>"
# Good - comma-separated for arrays
agent-craft entries/create --fields[items]=1,2,3
# Good - auto-indexed arrays
agent-craft entries/create --fields[items][]=1 --fields[items][]=2JSON Fallback (For Complex Nesting)
# Use JSON strings for deeply nested structures
agent-craft entries/create --fields[matrix]='[{"type":"block","data":{...}}]'Type Handling
- Numbers are automatically detected:
--sectionId=1becomes integer1 - Booleans:
--enabled=trueor--enabled=false - Strings: anything else remains a string
- Arrays: comma-separated or repeated
[]flags - Let Valinor handle final type casting based on tool method signatures
Building from Source
Prerequisites
- PHP 8.1 or higher
- Composer
phar.readonlydisabled (either in php.ini or via CLI flag)
Build Process
The build script (bin/build-phar.php) creates a self-contained PHAR executable with:
- Plugin Source Code: All files from
src/directory - CLI Entrypoint: The
bin/agent-craftscript - Minimal Autoloader: PSR-4 autoloader for the plugin's namespace
The PHAR does NOT include Craft CMS or vendor dependencies. Instead, it:
- Loads the plugin's code from the PHAR archive
- Bootstraps Craft CMS from the target installation (specified via --path or current directory)
- Uses Craft's autoloader for all dependencies (Valinor, Craft core, etc.)
This architecture keeps the PHAR small (under 1 MB) while ensuring it works with any Craft installation.
Build Command
# From the plugin repository
cd /path/to/craft-skill
# Build the PHAR
php -d phar.readonly=0 bin/build-phar.php
# Output: agent-craft.phar in project rootBuild Output
The build script provides progress information:
Building PHAR: /path/to/agent-craft.phar
Added: autoload.php
Added: 58 files from src/
Added: 437 files from vendor/cuyz/valinor/
Added: bin/agent-craft.php
PHAR built successfully!
Output: /path/to/agent-craft.phar
Size: 915 KB
Files: 497 totalDistribution
After building, you can distribute agent-craft.phar as a single file. Users only need:
- PHP 8.1+ installed
- A Craft CMS project to point the tool at
No Composer dependencies, no installation steps - just run the PHAR with --path pointing to a Craft installation.
License
MIT License - see LICENSE for details.
Credits
Built by Happy Cog for the Craft CMS community.
Installationen
Sicherheitsprüfung
Quellcode ansehen
happycog/craft-skill
Mehr aus dieser Quelle
So verwenden Sie diesen Skill
Install craft cms skills by running npx skills add happycog/craft-skill --skill craft cms skills in your project directory. Führen Sie den obigen Installationsbefehl in Ihrem Projektverzeichnis aus. Die Skill-Datei wird von GitHub heruntergeladen und in Ihrem Projekt platziert.
Keine Konfiguration erforderlich. Ihr KI-Agent (Claude Code, Cursor, Windsurf usw.) erkennt installierte Skills automatisch und nutzt sie als Kontext bei der Code-Generierung.
Der Skill verbessert das Verständnis Ihres Agenten für craft cms skills, und hilft ihm, etablierte Muster zu befolgen, häufige Fehler zu vermeiden und produktionsreifen Code zu erzeugen.
Was Sie erhalten
Skills sind Klartext-Anweisungsdateien — kein ausführbarer Code. Sie kodieren Expertenwissen über Frameworks, Sprachen oder Tools, das Ihr KI-Agent liest, um seine Ausgabe zu verbessern. Das bedeutet null Laufzeit-Overhead, keine Abhängigkeitskonflikte und volle Transparenz: Sie können jede Anweisung vor der Installation lesen und prüfen.
Kompatibilität
Dieser Skill funktioniert mit jedem KI-Coding-Agenten, der das skills.sh-Format unterstützt, einschließlich Claude Code (Anthropic), Cursor, Windsurf, Cline, Aider und anderen Tools, die projektbezogene Kontextdateien lesen. Skills sind auf Transportebene framework-agnostisch — der Inhalt bestimmt, für welche Sprache oder welches Framework er gilt.
Chat with 100+ AI Models in one App.
Use Claude, ChatGPT, Gemini alongside with EU-Hosted Models like Deepseek, GLM-5, Kimi K2.5 and many more.