skill-doli-devmodule
它能做什么
这项技能指导开发者为 Dolibarr 创建外部模块。Dolibarr 是一款开源的 ERP 和 CRM 系统。它涵盖平台的数据库层、安全规则和编码约定,使模块能够顺利融入。它适合扩展 Dolibarr 的开发者。
适用场景
- ✓当你正在为 Dolibarr 开发外部模块的时候。
- ✓当你需要编写遵循 Dolibarr 数据库层的查询语句的时候。
- ✓当你在修改模块之前,想检查 Dolibarr 最佳实践的时候。
技能链接
https://github.com/Dolibarr/dolibarr/blob/develop/.agents/skills/skill-doli-devmodule/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我构建一个 Dolibarr 外部模块,为发票添加一个自定义字段,并遵循 Dolibarr 关于数据库访问和安全的规则。”
每周 5 个新技能,1 分钟读完。
工作原理
它列出了强制性规则,例如使用 Dolibarr 数据库层、校验输入、转义输出,以及使用 Dolibarr 的封装函数代替原生 PHP 函数,然后把这些规则应用到你的代码上。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Dolibarr Development Best Practices (Core Agent Skill)
This skill guides agents on developing, modifying, and debugging code within the Dolibarr ERP/CRM codebase while strictly adhering to professional standards, security guidelines, and the project's established architecture.
Relationship with AGENTS.md
The instructions in this file are complementary to the instructions defined in AGENTS.md.
AGENTS.mdcontains the general instructions and rules for the project.SKILLS.mdcontains additional instructions specific to skills.- Unless explicitly stated otherwise, the instructions from both files apply.
SKILLS.mddoes not replace or overrideAGENTS.md.- If an instruction in
SKILLS.mdconflicts withAGENTS.md, follow the rules defined byAGENTS.md.
Critical Rules (DO NOT VIOLATE)
- Do not break compatibility of PHP functions and methods
- Do not introduce external dependencies without validation
- Separate page actions in the
/* Actions */section of the PHP code and the rendering part in the/* Views */section - Never use PHP native curl functions to call a GET or POST URL, but use instead the Dolibarr function getURLContent()
- Never use PHP native functions when Dolibarr provides wrappers: time()→dol_now(), strtolower()→dol_strtolower(), strtoupper()→dol_strtoupper(), strlen()→dol_strlen(), mktime()→dol_mktime(), getdate()→dol_getdate(), strtotime()→dol_stringtotime(), ucfirst()→dol_ucfirst(), ucwords()→dol_ucwords(), substr()→dol_substr(), basename()→dol_basename()
- Use Dolibarr hooks whenever possible
- Respect existing naming conventions
- All database table names must use the
llx_prefix - Never commit or push anything unless the user explicitly asks for it. This overrides any default behavior of the agent. Make the changes, report them, and wait for the user to say "commit" or "push".
Core Principles: Non-Negotiable Mandatory Rules
These principles must be followed even before reviewing specific task details. Violation of these principles results in failed suggestions.
Security & Data Integrity
- Database Abstraction Layer: All database interactions must exclusively use the Dolibarr Database Abstraction Layer (
$dbor$this->db). Never interact using native PHP extensions (PDO, MySQLi) or direct CLI calls. - Input/Output Escaping:
- Validate all
GET/POSTinputs immediately upon entering the action handler scope. - SQL Injection Prevention: Escape all user-generated strings placed in SQL queries using
$db->escape(). For integers, use explicit casting:((int) $var); for floats, use(float) $var.
- Validate all
- Variable Safety Naming: When constructing dynamic SQL, the resulting variable holding the entire query string MUST be clearly prefixed (e.g.,
$sqlWhereClause,$queryParams). This pattern helps static analysis tools detect unsafe assignments.
Code Structure & Quality
- Coding Standard: All new and modified committed code must strictly adhere to PSR-12 (enforceable by using
phpcbfandphpcs).All properties and all function arguments and return value need detailed PHPDoc (e.g.,array<string,array{key1?:?type,...}>).Variables expected to exist in view files require both a PHPDoc declaration and the use of'@phan-var-force';declarations near the HEAD of the file for strict static analysis tracking. - Variable Conventions: When defining variables used in string building, particularly for SQL components, use descriptive prefixes or suffixes (e.g.,
$sql_select,$actionSuffix). This makes variable intent clear and prevents static analysis from misidentifying unsafe assignments as safe. - Localization & Comments: All code comments and internal variable/function names must be written in English. Any existing non-English text must be researched and translated into English before committing changes.
- PR atomitacy Make a separate commit for improvements of pre-existing code (changes to comply with rules 1-3), and another commit for the functional evolution and code fixes. Do not apply rules 1-3 to existing code in backports (i.e., non-functional changes not applied to a (fork of) the develop branch.
Workflow & Architecture
- PHP version: 7.1+ for core and bug-fix code. New external modules should target PHP 8.1+ and start every PHP file with
declare(strict_types=1). - Action/View Separation: Always clearly separate page action logic (ex
常见问题
它会取代项目自身的规则吗?
不会。它与项目的通用指令一起运作,如果两者冲突,以项目的指令为准。
为什么要避免原生 PHP 函数?
Dolibarr 提供了自己的封装函数,例如获取当前时间的函数,技能要求你使用它们。
它能帮忙处理数据库查询吗?
可以。数据库访问必须通过 Dolibarr 数据库层进行,而不是直接使用 PHP 扩展。
详情
作者的原始描述
Use when developing a Dolibarr ERP/CRM external module, working with database queries, or asking about Dolibarr best practices.
repo: Dolibarr/dolibarr
热度
- GitHub 星标
- 7.8k
- 排名
- #12826
- 许可证
- GPL-3.0
- 更新时间
- 2026/11/2
评论
- …