Espocrm logo

Espocrm

Community
bobmatnyc
espocrm

Comprehensive guide for developing on EspoCRM - metadata-driven CRM with service layer architecture

Overview

Publisherbobmatnyc
Repositoryclaude-mpm-skills
Skill nameespocrm
Stars
75
Forks
19
Bundled files
12
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 12 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by bobmatnyc on GitHub. Read the source before you install it.

Installation

Install the Espocrm AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/bobmatnyc/claude-mpm-skills.git /tmp/claude-mpm-skills
mkdir -p .claude/skills
cp -r /tmp/claude-mpm-skills/toolchains/php/frameworks/espocrm .claude/skills/espocrm
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Espocrm in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Espocrm on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Espocrm is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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), building custom field types, creating complex queries with SelectBuilder, implementing custom API actions, or packaging extensions.

The Iron Law

BUSINESS LOGIC IN SERVICES, NOT HOOKS | DATA ACCESS VIA ENTITYMANAGER, NEVER DIRECT PDO | NEVER PASS CONTAINER AS DEPENDENCY

Accessing Container directly or writing business logic in hooks violates architecture.

Core Architecture Principles

  1. Metadata-Driven: Entity definitions, layouts, field configs live in JSON
  2. Service Layer: All business logic implemented in Service classes
  3. ORM EntityManager: Central access point for all database operations
  4. Dependency Injection: Constructor injection, never pass Container
  5. Hook System: Lifecycle events for validation and side effects (not business logic)
  6. Repository Pattern: Entities accessed through repositories

Quick Start

  1. Setup Development Environment - Use ext-template, work in src/ directory (EspoCRM 7.4+), understand metadata structure: custom/Espo/Modules/{ModuleName}/Resources/metadata/

  2. Access Data with EntityManager

    php
    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();
  3. Implement Business Logic in Services

    php
    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;
        }
    }
  4. Register Hooks for Lifecycle Events

    php
    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
            }
        }
    }
  5. Rebuild Cache After Changes

    bash
    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

Core Concepts

  • 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

Advanced Topics

  • SelectBuilder: Advanced querying with SelectBuilder - complex queries, joins, aggregations, and query optimization
  • API Actions: Creating custom API endpoints - action handlers, request/response patterns, and authentication
  • Custom Field Types: Building custom field types - backend, frontend, metadata, and integration

UI and Integration

  • Frontend Customization: View system, client-side development, and UI customization
  • Common Tasks: Scheduled jobs, emails, PDFs, ACL, workflows, and integration patterns
  • Extension Packages: Packaging and distributing extensions - manifest files, installation, and versioning

Quality Assurance

Key Patterns

Correct Pattern:

php
✅ Service with injected dependencies
✅ EntityManager for data access
✅ Hooks using interfaces
✅ Type declarations on all methods
✅ Exceptions for error handling

Incorrect Patterns:

php
❌ 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 Services
  • Always rebuild cache - After metadata changes (bin/command rebuild)
  • Use interfaces for hooks - Not base classes
  • Type everything - PHP 7.4+ requires type declarations
  • Throw exceptions - Don't return booleans for errors

Integration with Other Skills

  • systematic-debugging: Debug EspoCRM issues using logs and step debugging
  • verification-before-completion: Always test with cache rebuild before claiming complete
  • test-driven-development: Write unit tests for Services and hooks

The Bottom Line

EspoCRM is metadata-driven with a service layer architecture.

Understand the metadata system. Use EntityManager for data. Implement business logic in Services. Use hooks for lifecycle events only. Rebuild cache after changes.

This is the EspoCRM way.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Espocrm AI skill do?

Comprehensive guide for developing on EspoCRM - metadata-driven CRM with service layer architecture

Why use Espocrm on TypingMind?

Because you install it once and use it with any model. Espocrm is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Espocrm in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/bobmatnyc/claude-mpm-skills/tree/main/toolchains/php/frameworks/espocrm. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Espocrm?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Espocrm?

As many as you like. As long as a model supports skills, you can use Espocrm with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Espocrm AI skill free?

Yes. It is published on GitHub by bobmatnyc under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇