espocrm-development
БесплатноБез исполняемых скриптовНе проверенComprehensive guide for developing on EspoCRM - metadata-driven CRM with service layer architecture
Об этом скилле
EspoCRM Development
Overview
EspoCRM is a metadata-driven CRM platform where configuration lives in JSON files, business logic belongs in Services, and data access happens through ORM EntityManager. This skill enforces architectural patterns to prevent common mistakes like passing Container dependencies, bypassing the service layer, or implementing business logic in hooks.
When to Use This Skill
Activate when developing custom EspoCRM modules, entities, relationships, hooks, services, API endpoints, or integrations. Use especially when: working with ORM (EntityManager required), implementing business logic (belongs in Services), creating hooks (use interfaces), modifying metadata (requires cache rebuild), or building custom field types.
The Iron Law
BUSINESS LOGIC IN SERVICES, NOT HOOKS | DATA ACCESS VIA ENTITYMANAGER, NEVER DIRECT PDO | NEVER PASS CONTAINER AS DEPENDENCY
If you're accessing Container directly or writing business logic in hooks, you're violating architecture.
Core Architecture Principles
- Metadata-Driven: Entity definitions, layouts, field configs live in JSON
- Service Layer: All business logic implemented in Service classes
- ORM EntityManager: Central access point for all database operations
- Dependency Injection: Constructor injection, never pass Container
- Hook System: Lifecycle events for validation and side effects (not business logic)
- Repository Pattern: Entities accessed through repositories
Quick Start
Setup Development Environment - Use ext-template, work in
src/directory (EspoCRM 7.4+), understand metadata structure:custom/Espo/Modules/{ModuleName}/Resources/metadata/Access Data with EntityManager
use Espo\ORM\EntityManager; public function __construct(private EntityManager $entityManager) {} // Find entity $account = $this->entityManager->getEntityById('Account', $id); // Query with conditions $collection = $this->entityManager ->getRDBRepository('Contact') ->where(['accountId' => $accountId]) ->find();Implement Business Logic in Services
namespace Espo\Modules\MyModule\Services; use Espo\Services\Record; class MyEntity extends Record { public function customAction(string $id, object $data): object { // Business logic here $entity = $this->entityManager->getEntityById($this->entityType, $id); // ... process ... $this->entityManager->saveEntity($entity); return $entity; } }Register Hooks for Lifecycle Events
namespace Espo\Modules\MyModule\Hooks\Account; use Espo\ORM\Entity; use Espo\Core\Hook\Hook\BeforeSave; class MyHook implements BeforeSave { public function beforeSave(Entity $entity, array $options): void { // Validation or side effects only if ($entity->isAttributeChanged('status')) { // React to changes } } }Rebuild Cache After Changes
bin/command rebuild
Hook Types (Interfaces)
EspoCRM provides 7 hook types - ALWAYS use interfaces: BeforeSave (validation before save), AfterSave (side effects after save), BeforeRemove (validation before delete), AfterRemove (cleanup after delete), AfterRelate (relationship creation), AfterUnrelate (relationship removal), AfterMassRelate (bulk relationship operations).
Navigation
For detailed information:
- Architecture: Metadata system, ORM, DI container, repository pattern, and core architectural patterns
- Development Workflow: Module creation, custom entities, fields, APIs, and extension development process
- Hooks and Services: Service layer implementation, hook types, dependency injection, and business logic patterns
- Frontend Customization: View system, client-side development, and UI customization
- Common Tasks: Scheduled jobs, emails, PDFs, ACL, workflows, and integration patterns
- Testing and Debugging: Unit tests, debugging techniques, performance optimization, and common pitfalls
Key Patterns
Correct Pattern:
✅ Service with injected dependencies
✅ EntityManager for data access
✅ Hooks using interfaces
✅ Type declarations on all methods
✅ Exceptions for error handling
Incorrect Patterns:
❌ Passing Container as dependency
❌ Direct PDO database access
❌ Business logic in hooks
❌ Hook base classes instead of interfaces
❌ Missing type declarations
Common Mistakes to Avoid
- Never pass Container - Inject specific dependencies instead
- Don't bypass EntityManager - Use ORM, not raw queries
- Business logic doesn't belong in hooks - Use Ser
Установить espocrm-development в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл espocrm-development?
Comprehensive guide for developing on EspoCRM - metadata-driven CRM with service layer architecture
Как установить скилл espocrm-development?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл espocrm-development запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
gtm-enterprise-account-planning
Strategic account planning and execution for enterprise deals. Use when planning complex sales cycles, managing multiple stakeholders, applying MEDDICC…
от GitHubgtm-partnership-architecture
Build and scale partner ecosystems that drive revenue and platform adoption. Use when building partner programs from scratch, tiering partnerships, managing…
от GitHublanding-page-conversion-audit
Audit a landing page, sales page or checkout page for conversion leaks and return a fix list ordered by expected revenue impact. Use when asked to review…
от GitHubpower-platform-architect
Use this skill when the user needs to transform business requirements, use case descriptions, or meeting transcripts into a technical Power Platform solution…
от GitHub