skill-doli-devmodule
Skill này làm gì
Skill này hướng dẫn lập trình viên tạo một module bên ngoài cho Dolibarr, một ERP và CRM mã nguồn mở. Skill bao gồm lớp cơ sở dữ liệu, quy tắc bảo mật và quy ước code của nền tảng để module khớp với hệ thống. Skill dành cho lập trình viên mở rộng Dolibarr.
Khi nào nên dùng
- ✓Khi bạn đang phát triển một module bên ngoài cho Dolibarr.
- ✓Khi bạn cần viết truy vấn cơ sở dữ liệu theo lớp cơ sở dữ liệu của Dolibarr.
- ✓Khi bạn muốn kiểm tra các thực hành tốt nhất của Dolibarr trước khi thay đổi một module.
Liên kết skill
https://github.com/Dolibarr/dolibarr/blob/develop/.agents/skills/skill-doli-devmodule/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Giúp tôi xây dựng một module Dolibarr bên ngoài để thêm một trường hóa đơn tùy chỉnh, tuân theo quy tắc của Dolibarr về truy cập cơ sở dữ liệu và bảo mật.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill nêu các quy tắc bắt buộc, như dùng lớp cơ sở dữ liệu của Dolibarr, kiểm tra đầu vào, escape đầu ra và dùng các hàm wrapper của Dolibarr thay cho hàm PHP gốc, rồi áp dụng chúng vào code của bạn.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Skill có thay thế quy tắc riêng của dự án không?
Không. Nó hoạt động cùng với hướng dẫn chung của dự án, và hướng dẫn đó được ưu tiên nếu hai bên mâu thuẫn.
Vì sao tránh hàm PHP gốc?
Dolibarr cung cấp các hàm wrapper riêng, như một hàm lấy thời gian hiện tại, và skill yêu cầu bạn dùng chúng.
Nó có giúp về truy vấn cơ sở dữ liệu không?
Có. Truy cập cơ sở dữ liệu phải đi qua lớp cơ sở dữ liệu của Dolibarr, không dùng các tiện ích PHP trực tiếp.
Chi tiết
Mô tả gốc của tác giả
Use when developing a Dolibarr ERP/CRM external module, working with database queries, or asking about Dolibarr best practices.
repo: Dolibarr/dolibarr
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #12826
- Giấy phép
- GPL-3.0
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.