[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ACQA1CZ2QW6GAM6HPFR21V":3,"skill-same:01M6ACQA1CZ2QW6GAM6HPFR21V":58},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":17,"categories":18,"keywords":29,"publishedAt":31,"linkOnly":32,"markdownContent":33,"markdownBody":33,"frontMatter":34,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":38,"repositoryHtmlUrl":39,"repositoryHomepageUrl":40,"ownerHtmlUrl":41,"ownerBlogUrl":42,"ownerDescription":7,"updatedAt":43,"install":44,"resources":57},"01M6ACQA1CZ2QW6GAM6HPFR21V","manage-services","服务管理",null,"","apache\u002Fofbiz-plugins","apache","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F47359?v=4","01M6AC83E6K4FDKK7HZ8WNMQKE","The Apache Software Foundation","01M6ACMJJ1Q4WYATY4GXZ2FAVD",178,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-services\u002FSKILL.md",[19,24],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",{"categoryNo":25,"categoryName":26,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8C36CP2J9CRK1B6PYRXVHPN","应用配置管理","SCENARIO","使用场景",[30],"manage services","2026-11-10 10:12:30",false,"\u003C!--\nLicensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\nhttp:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied.  See the License for the\nspecific language governing permissions and limitations\nunder the License.\n-->\n\n---\nname: manage-services\ndescription: Define and implement OFBiz services. Use when creating new services in services.xml, modifying attributes, orchestrating execution, or debugging dispatcher.\n---\n\n# Skill: manage-services\n\n## Goal\nDefine and implement business logic as reusable, transactional, and securely enforced OFBiz services.\n\n## Triggers\n**ALWAYS** read this skill when:\n- Defining or modifying `servicedef\u002Fservices.xml`.\n- Registering services in `ofbiz-component.xml`.\n- Implementing service logic in Java, Groovy, or MiniLang.\n- Troubleshooting service execution, validation, transactions, or asynchronous behavior.\n- Exposing business logic to the UI or API.\n- Orchestrating complex data workflows. (**Cross-Reference**: See the `manage-service-groups` skill for orchestrating sequential or concurrent flows without complex branching)\n- Handling transactional operations (e.g., database commit\u002Frollback boundaries).\n- Dispatching asynchronous jobs or delayed callbacks.\n\n## Rules & Procedures\n\n### 1. Engine Selection\n- **`entity-auto`**: Use for standard CRUD (Create, Update, Delete). Highly efficient; eliminates manual boilerplate.\n- **`groovy`**: Use for logic requiring entity queries, map manipulation, parameter adaptations, or UI preparation. Fast to write, minimal boilerplate.\n- **`java`**: Use for core domain invariants, strict compile-time typing, performance-heavy transformations, heavy loops, or integrating with 3rd-party libraries.\n- **`group`**: Use as a simple orchestration wrapper for multiple independent services sequentially. Replaces the need to write an orchestration script. (**Cross-Reference**: See the `manage-service-groups` skill for group definitions, execution modes (`send-mode`), and orchestration anti-patterns.)\n\n### 2. Service Definition & Registration\n- **Naming**: Use `verbNoun` format for all service names (e.g., `updateExample`, `createOrder`).\n- **In\u002FOut Parameters**: Use `\u003Cattribute name=\"...\" mode=\"IN|OUT|INOUT\" type=\"...\" optional=\"true|false\"\u002F>`. NEVER bypass attribute validation by casually omitting them or making them wrongly optional.\n- **Native Contract Types**: Backend\u002Fdata services should keep OFBiz-native service types such as `Timestamp` and `BigDecimal` in IN\u002FOUT attributes and returned maps.\n- **Type In XML First**: If a service consumes dates, numbers, or booleans, declare them with native OFBiz\u002FJava types in `services.xml` first. Prefer fixing the service contract over keeping Groovy-side parsing code forever.\n- **Auth & Security**: Set `auth=\"true\"` for protected services. ALWAYS implement permission checks (e.g., `\u003Cpermission-service>`).\n- **Export & REST**: Set `export=\"true\"` to expose the service to external callers. Set `action=\"GET|POST|PUT|DELETE\"` to automatically export the service as a REST API endpoint.\n- **Service Overrides**: Use `\u003Cimplements service=\"...\" \u002F>` to inherit attributes from an existing service.\n- **Registration**: Ensure `services.xml` is registered in `ofbiz-component.xml` via `\u003Cservice-resource type=\"model\" loader=\"main\" location=\"servicedef\u002Fservices.xml\"\u002F>`.\n\n### 3. Execution & Handling\n- **Request Processing**: Access parameters via `context` (Map). All services MUST return success\u002Ferror maps via `ServiceUtil` (Java) or DSL shorthands (Groovy).\n- **Synchronous (`runSync`)**: Use when the system depends on an immediate computation result or necessitates atomicity and immediate data consistency.\n- **Asynchronous (`runAsync`)**: Use for heavy processing operations or external API integrations spanning across latency. **Cross-Reference**: See the `manage-async` skill for detailed guidelines.\n- **Asynchronous Callbacks**: For long-running operations where you want to react without polling, use `dispatcher.registerCallback`.\n\n### 4. Transaction Management (`use-transaction` & `require-new-transaction`)\n- **Same Transaction (Default)**: Default is `use-transaction=\"true\"`. Suitable for parent-child updates where all must succeed or fail together.\n- **Different Transaction**: Use `require-new-transaction=\"true\"` to isolate failures from the parent (e.g., Audit Logging so errors aren't wiped, Sequence Counters, Massive Batches).\n\n### 5. Business Transactions (Rollback vs. Commit Services)\n- **Commit Services**: Use `dispatcher.addCommitService` or SECAs on `global-commit` to run a service *only after* the transaction commits (e.g., sending emails). **Cross-Reference**: See the `manage-eca` skill for clear distinctions between `commit` and `global-commit`.\n- **Rollback Services**: Use `dispatcher.addRollbackService` or SECAs on `global-rollback` to run a compensating service *only if* the target transaction rolls back entirely (e.g., releasing external payment holds).\n\n### 6. Architecture & Composition\n- OFBiz services can cleanly be invoked via Internal Dispatch, the Controller web layer, Scheduled Jobs, Form\u002FWidget layers, or External API integration.\n- **Cross-Reference**: See the `manage-eca` skill for deep dives into event-driven architecture mapping (SECAs\u002FEECAs) configurations and patterns.\n\n## Guardrails\n\n### 1. View vs. Business Logic Separation\n- Services must remain completely agnostic of the View layer. NEVER put HTML encoding, FreeMarker syntax, or UI formatting into a core backend service.\n- Do not stringify dates, timestamps, quantities, or money in backend data services unless the service is explicitly a presentation\u002Fexport formatting service.\n- Error Messages: Use properties from `uiLabelMap` for user-facing error messages to support internationalization.\n\n### 2. Error Handling Integrity\n- **Swallowing Errors via Dispatcher**: When invoking a sub-service with `dispatcher.runSync()`, ALWAYS check manually using `ServiceUtil.isError(result)`. Failing to check will mask business failures and block rollbacks.\n- **Null Safety**: Always check for mandatory attributes in implementation if not strictly enforced by XML validation.\n\n### 3. Transaction Boundaries\n- **Hidden Dangers of Async Services**: Never dispatch async services that rely on uncommitted data from the current transaction. They run concurrently and might trigger an intermittent \"record not found\". Use SECAs on `commit` or `global-commit` instead. **Cross-Reference**: See `manage-eca` on how to configure this correctly.\n- **Programmatic Transactions**: NEVER handle `TransactionUtil.begin()` or `TransactionUtil.commit()` manually within Java code. Configure transactions strictly using `require-new-transaction` in `services.xml`. Let the service engine manage persistence and rollbacks.\n\n### 4. Boilerplate CRUD Avoidance\n- Do NOT use a Java or Groovy service simply to write `delegator.create()`. Rely on the `entity-auto` engine.\n\n### 5. API Wrapper Services\n- Thin API wrappers may adapt naming, shape, or multi-call orchestration for a PWA or REST endpoint, but they should still preserve OFBiz-native types in the service contract.\n- Do not stringify timestamps, quantities, or money in wrapper services unless the service is explicitly a presentation\u002Fexport formatter.\n- For multi-column primary keys exposed through a single REST path segment, use a stable composite ID mapping in the API wrapper rather than flattening the underlying entity model.\n\n## Anti-Patterns\n\n### Anti-Pattern 1: Swallowing Errors in runSync\nIf you do not return the error from a sub-service, the parent service thinks it succeeded and commits the transaction, leaving your system in an inconsistent state.\n\n**Bad:**\n```groovy\ndef processOrder() {\n    \u002F\u002F Calling sub-service but ignoring the result!\n    dispatcher.runSync(\"chargeCreditCard\", [orderId: context.orderId]) \n    \n    \u002F\u002F This will run even if the credit card was declined!\n    dispatcher.runSync(\"approveOrder\", [orderId: context.orderId])\n    return ServiceUtil.returnSuccess()\n}\n```\n\n**Good:**\n```groovy\ndef processOrder() {\n    Map chargeResult = dispatcher.runSync(\"chargeCreditCard\", [orderId: context.orderId])\n    if (ServiceUtil.isError(chargeResult)) {\n        return chargeResult \u002F\u002F Returns error upwards, triggers parent rollback!\n    }\n    \n    dispatcher.runSync(\"approveOrder\", [orderId: context.orderId])\n    return ServiceUtil.returnSuccess()\n}\n```\n\n### Anti-Pattern 2: Manual Transaction Management\nManually managing database connections and transactions bypasses the service engine's ability to trigger SECAs, coordinate distributed transactions, and handle rollbacks consistently.\n\n**Bad:**\n```java\npublic static Map\u003CString, Object> myBadService(DispatchContext dctx, Map\u003CString, ? extends Object> context) {\n    boolean beganTransaction = false;\n    try {\n        beganTransaction = TransactionUtil.begin();\n        \u002F\u002F ... DB updates\n        TransactionUtil.commit(beganTransaction);\n    } catch (Exception e) {\n        TransactionUtil.rollback(beganTransaction, \"Error\", e);\n    }\n    return ServiceUtil.returnSuccess();\n}\n```\n\n**Good:**\nConfigure it in `services.xml` instead and let the engine handle it automatically.\n```xml\n\u003C!-- In services.xml -->\n\u003Cservice name=\"myGoodService\" engine=\"java\" ... use-transaction=\"true\" require-new-transaction=\"true\">\n\u003C\u002Fservice>\n```\n\n### Anti-Pattern 3: Writing Boilerplate CRUD\nWriting custom Groovy\u002FJava code just to perform basic CRUD operations is a waste of time and introduces potential bugs.\n\n**Bad:** (Groovy file)\n```groovy\ndef createExample() {\n    GenericValue example = delegator.makeValue(\"Example\")\n    example.setPKFields(context)\n    example.setNonPKFields(context)\n    example.create()\n    return ServiceUtil.returnSuccess()\n}\n```\n*(Plus the XML definition using engine=\"groovy\")*\n\n**Good:** (Only needs XML definition)\n```xml\n\u003Cservice name=\"createExample\" engine=\"entity-auto\" invoke=\"create\" default-entity-name=\"Example\" auth=\"true\">\n    \u003Cauto-attributes mode=\"IN\" include=\"nonpk\" optional=\"true\"\u002F>\n    \u003Cauto-attributes mode=\"OUT\" include=\"pk\" optional=\"false\"\u002F>\n\u003C\u002Fservice>\n```\n\n### Anti-Pattern 4: Async Execution on Uncommitted Data\nDispatching an async service before the data it needs is committed leads to intermittent \"record not found\" errors because the async thread might start querying before the main thread commits.\n\n**Bad:**\n```groovy\ndef createOrder() {\n    \u002F\u002F 1. Create order in DB (uncommitted in current transaction)\n    delegator.create(orderHeader) \n    \n    \u002F\u002F 2. DANGER: Async thread starts running NOW, might fetch orderHeader before step 1 commits\n    dispatcher.runAsync(\"sendOrderConfirmationEmail\", [orderId: orderHeader.orderId]) \n    \n    return ServiceUtil.returnSuccess()\n}\n```\n\n**Good:**\nUse a SECA triggered on `global-commit` so it only runs *after* the data is safely in the database and the parent transaction has entirely succeeded. See the **`manage-eca`** skill for detailed examples of `global-commit` vs `commit`.\n```xml\n\u003C!-- In secas.xml -->\n\u003Ceca service=\"createOrder\" event=\"global-commit\">\n    \u003Caction service=\"sendOrderConfirmationEmail\" mode=\"async\"\u002F>\n\u003C\u002Feca>\n```\n\n## Examples\n\n**Example: Service implementation in Groovy**\n```groovy\ndef updateExample() {\n    Map result = ServiceUtil.returnSuccess()\n    GenericValue example = from(\"Example\").where(\"exampleId\", context.exampleId).queryOne()\n    if (example) {\n        example.setNonPKFields(context)\n        example.store()\n    }\n    return result\n}\n```\n\n**Example: Asynchronous Callback Configuration (Java)**\nInstead of hard-wiring logic, react to long-running services:\n```java\ndispatcher.registerCallback(\"getTrackingNumberFromCarrier\", new GenericServiceCallback() {\n    @Override\n    public void receiveEvent(Map\u003CString,Object> ctx, Map\u003CString,Object> res) {\n        Debug.logInfo(\"Carrier response received. Tracking ID: \" + res.get(\"trackingNumber\"), \"MyModule\");\n    }\n    @Override\n    public boolean isEnabled() { return true; }\n});\n```\n\n**Example: Compensating Rollback Service (Java)**\nIf the database rolls back, execute logic to cancel an external hold:\n```java\ndispatcher.addRollbackService(\"releaseAuthorization\", context, true);\n```\n\n**Example: REST Export in Service Definition**\n```xml\n\u003Cservice name=\"findProductById\" engine=\"java\" auth=\"true\" export=\"true\" action=\"GET\"\n         location=\"org.apache.ofbiz.product.product.ProductServices\" invoke=\"findProductById\">\n    \u003Cdescription>Automatically exported as a REST API\u003C\u002Fdescription>\n    \u003Cattribute name=\"productId\" mode=\"IN\" type=\"String\" optional=\"false\"\u002F>\n\u003C\u002Fservice>\n```\n",{},"trunk","6c6c27710443de03e9247605d33a2e2f5bc3d1e2","ai-agent-skills\u002Fmanage-services",222,"https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins","https:\u002F\u002Fofbiz.apache.org\u002F","https:\u002F\u002Fgithub.com\u002Fapache","https:\u002F\u002Fwww.apache.org\u002F","2026-11-12 22:04:06",{"source":9,"skillName":5,"commands":45,"prompt":55,"zipAvailable":56},[46,49,52],{"tool":47,"command":48},"npx","npx skills add apache\u002Fofbiz-plugins --skill manage-services",{"tool":50,"command":51},"bunx","bunx skills add apache\u002Fofbiz-plugins --skill manage-services",{"tool":53,"command":54},"pnpm","pnpm dlx skills add apache\u002Fofbiz-plugins --skill manage-services","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-services\u002FSKILL.md",true,[],[59,71,83,97,111,125],{"skillNo":60,"name":61,"nameZh":62,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":63,"categories":64,"keywords":69,"publishedAt":31},"01M6ACQSN90YKJZ92MQ52D9R8H","prepush-readiness","推送前就绪检查","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fprepush-readiness\u002FSKILL.md",[65,66],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":67,"categoryName":68,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BR5V701HCN066VEP7H4812","代码仓库协作管理",[70],"prepush readiness",{"skillNo":72,"name":73,"nameZh":74,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":75,"categories":76,"keywords":81,"publishedAt":31},"01M6ACQPR1WRA751V4DXVC3AHF","manage-webapps","Web 应用管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-webapps\u002FSKILL.md",[77,78],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":79,"categoryName":80,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BWKS60NTYJHFE9FQSXGDKS","低代码应用开发",[82],"manage webapps",{"skillNo":84,"name":85,"nameZh":86,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":87,"categories":88,"keywords":95,"publishedAt":31},"01M6ACQMCX8Z7NY2CE08NCV6ND","manage-themes","主题管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-themes\u002FSKILL.md",[89,92],{"categoryNo":90,"categoryName":91,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQ6TQMKHSMFVQHR2KYAEVN","界面设计师",{"categoryNo":93,"categoryName":94,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BRASNPVNJVQQJ4KZX8XM5D","前端开发与界面实现",[96],"manage themes",{"skillNo":98,"name":99,"nameZh":100,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":101,"categories":102,"keywords":109,"publishedAt":31},"01M6ACQHYN20AFWF6TKK4RGQ8A","manage-tests","测试管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-tests\u002FSKILL.md",[103,106],{"categoryNo":104,"categoryName":105,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQGD5WG86P4AQ5GPSSKBFR","测试工程师",{"categoryNo":107,"categoryName":108,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQJH394GT47X57A9Q8G7HX","测试与质量保障",[110],"manage tests",{"skillNo":112,"name":113,"nameZh":114,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":115,"categories":116,"keywords":123,"publishedAt":31},"01M6ACQFRMW7R45YD3HRAXPGWF","manage-templates","模板管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-templates\u002FSKILL.md",[117,120],{"categoryNo":118,"categoryName":119,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQ6TK1MPB82068236GSXDE","文档处理",{"categoryNo":121,"categoryName":122,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQ6TPH3VQWKQZXV7EPF8VZ","办公行政人员",[124],"manage templates",{"skillNo":126,"name":127,"nameZh":128,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":129,"categories":130,"keywords":137,"publishedAt":31},"01M6ACQCSSDZQMD8VX2K3WRR93","manage-strategies","策略管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-strategies\u002FSKILL.md",[131,134],{"categoryNo":132,"categoryName":133,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BTXF8K9DFQC4T4TXVH0NMZ","策略与托管设置管理",{"categoryNo":135,"categoryName":136,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8C6RQ852C9AEJFCBGG1YA7S","IT 管理员",[138],"manage strategies"]