agentleFS
jeffsensojeffsenso/dolibarr-skills/skills/dolibarr-development/SKILL.md

dolibarr-development

Skill9 starsChanged 7 months agoMITView on GitHub

Dolibarr ERP/CRM developer skill. Use for: building or extending Dolibarr modules (external/custom), implementing hooks, triggers, DAO classes, SQL tables, menus, permissions, tabs, boxes, PDF templates, cron scripts. Covers both core contributor and external module developer workflows. Applies coding rules (PSR-12, SQL norms, MVC pattern, Active Record).

  • In this repositoryOne other file it gives its agents.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Table prefix: all tables prefixed llx_

    line 24
  2. Very specific:

    Use the built-in Module Builder (enable it in Setup → Modules, then click the bug icon top-right).

    line 42
  3. Very specific:

    Create mymodule/class/actions_mymodule.class.php with hook methods

    line 71
  4. Very specific:

    Use dol_include_once('/mymodule/class/myclass.class.php', 'MyClass') for module classes

    line 94
  5. Very specific:

    Use require_once DOL_DOCUMENT_ROOT.'/core/...' for Dolibarr core classes

    line 95

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Dolibarr Developer Skill

When to Use

  • Creating or extending a Dolibarr module (custom or external)
  • Implementing hooks (actions_mymodule.class.php) or triggers
  • Writing DAO/business object classes, SQL table definitions
  • Adding menus, tabs, permissions, boxes, exports, CSS/JS
  • Building cron/command-line scripts
  • Writing PDF/ODT document templates
  • Following Dolibarr coding rules (PHP, SQL, HTML norms)

Key Concepts

Architecture

  • MVC pattern: Controller (/* Actions */) + View (/* View */) in same PHP file
  • Active Record ORM: one class per table with CRUD methods
  • Global objects: $db, $user, $conf, $langs, $mysoc, $hookmanager, $extrafields
  • Module location: external modules live in htdocs/custom/mymodule/
  • Table prefix: all tables prefixed llx_

Module Entry Points

Extension pointWhen to use
HooksInject/replace code in existing pages without modifying core
TriggersReact to business events (invoice created, order validated…)
TabsAdd tabs on thirdparty, order, product, invoice… sheets
MenusAdd top-level or left-menu entries
BoxesAdd widgets on home page
ExtrafieldsAdd fields to existing objects (no module needed for simple cases)
PDF templatesCustomize generated PDF documents

Step-by-Step: Build a Module

1. Generate Skeleton

Use the built-in Module Builder (enable it in Setup → Modules, then click the bug icon top-right). It generates modMyModule.class.php, SQL files, DAO class, and page skeletons.

GitHub template: https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template

2. Module Descriptor (required)

File: htdocs/custom/mymodule/core/modules/modMyModule.class.php

See → Module Structure reference

3. SQL Tables (optional)

  • Files in mymodule/sql/llx_mytable.sql + llx_mytable.key.sql
  • Load via $this->_load_tables('/mymodule/sql/') in init()
  • Primary key always rowid INTEGER AUTO_INCREMENT PRIMARY KEY
  • Table prefix llx_, InnoDB engine, no DB triggers, no DELETE CASCADE

See → Coding Rules reference

4. DAO Class (optional)

File: mymodule/class/myobject.class.php

  • Copy from htdocs/modulebuilder/templates/class/myobject.class.php
  • Methods: create(), fetch(), update(), delete(), fetchAll()
  • DB access pattern: $db->begin() / $db->query() / $db->commit() or $db->rollback()

5. Hooks (optional)

  • Declare context in modMyModule.class.php: $this->module_parts = array('hooks' => array('thirdpartycard', 'orderlist'))
  • Create mymodule/class/actions_mymodule.class.php with hook methods
  • Disable + re-enable module after changing contexts (stored in DB)
  • Find contexts: search initHooks( in source. Find hook names: search executeHooks( in source.

See → Hooks & Triggers reference

6. Menus (optional)

Declare in $this->menu array in module descriptor.

  • fk_menu=0 + type='top' for top menu
  • fk_menu='fk_mainmenu=xxx' + type='left' for left sub-menu
  • perms field controls visibility by permission
  • user=0 internal, 1 external, 2 both

7. Tabs (optional)

Declare in $this->tabs array: 'objecttype:+tabcode:Title:langfile@mymodule:condition:/mymodule/page.php?id=__ID__'

Object types: thirdparty, order, invoice, product, contact, contract, propal, member, user…

8. Permissions (optional)

Declare in $this->rights array. Test with $user->rights->mymodule->action->subaction.

9. PHP Pages (optional)

  • Bootstrap: include main.inc.php (try multiple relative paths, see template)
  • Use dol_include_once('/mymodule/class/myclass.class.php', 'MyClass') for module classes
  • Use require_once DOL_DOCUMENT_ROOT.'/core/...' for Dolibarr core classes
  • CSS classes: liste_titre, pair/impair, flat, button
  • JS: pass $morejs array to llxHeader()

10. Setup Page (optional)

  • Create mymodule/admin/setup.php
  • Set $this->config_page_url = array("setup.php@mymodule") in descriptor

Packaging & Distribution


References

  • Module structure, descriptor, file tree
  • Hooks system & Triggers
  • Coding rules: PHP, SQL, HTML
  • Technical components: menus, tabs, permissions, DB, dates

Official Docs

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.