[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ADWPT618SWH2K5BH8BC1S2":3,"skill-same:01M7ADWPT618SWH2K5BH8BC1S2":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7ADWPT618SWH2K5BH8BC1S2","Z-Syst",null,"Z-Syst Pharmacy Management System - Comprehensive rules for building a professional pharmacy management system using Laravel. Covers products, stock, purchases, sales, invoices, prescriptions, finance, reports, and SaaS expansion. Follow strict engineering principles: clean architecture, service layer pattern, database-first design, and audit-trail tracking.","zyadgfh\u002FZ-Syst","zyadgfh","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F315854134?v=4","01M7ADRHWJWRARA2DA2E44GC1Q","ZyadGamal","01M7ADRHXRHC9RZ6BKNHAVGK7C",0,"MIT","https:\u002F\u002Fgithub.com\u002Fzyadgfh\u002FZ-Syst\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fz-syst-pharmacy\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: Z-Syst\ndescription: \"Z-Syst Pharmacy Management System - Comprehensive rules for building a professional pharmacy management system using Laravel. Covers products, stock, purchases, sales, invoices, prescriptions, finance, reports, and SaaS expansion. Follow strict engineering principles: clean architecture, service layer pattern, database-first design, and audit-trail tracking.\"\n---\n\n# Z-Syst Pharmacy Management System\n\nComprehensive development rules for building a professional pharmacy management system (PharmaMaster Pro) using Laravel. This skill ensures systematic, production-ready development following clean architecture, domain-driven design, and pharmacy-specific business logic.\n\n## When to Use This Skill\n\nUse this skill when working on **any aspect of a pharmacy management system**, including:\n\n| Module | When to Activate |\n|--------|-----------------|\n| **Products** | Creating\u002Fmanaging medications, inventory items, barcodes, SKUs, categories, manufacturers, pricing |\n| **Stock** | Implementing inventory tracking, stock batches, movements, FEFO, expiry alerts, low-stock warnings |\n| **Purchases** | Building purchase orders, GRN (Goods Received Notes), supplier management, payment tracking |\n| **Sales & Invoices** | Creating POS, invoices, returns\u002Frefunds, payment methods, discounts, taxes |\n| **Prescriptions** | Managing doctors, patients, prescription items, digital scrips, refills |\n| **Finance** | Implementing revenue\u002Fexpense tracking, general ledger, profit\u002Floss reports |\n| **Reports** | Generating sales reports, stock reports, purchase reports, financial statements |\n| **SaaS Features** | Multi-company, multi-branch, multi-warehouse support, subscription management |\n\nSkip this skill for: non-pharmacy projects, generic CRUD apps, learning\u002Ftutorial code, or projects not using Laravel.\n\n## Core Principles\n\n### 1. Ultimate Goal\n- Build a **professional pharmacy system** ready for real-world use\n- Strong management of: Products, Stock, Purchases, Sales, Prescriptions, Finance, and Reports\n- Suitable for a real pharmacy first, then expandable to SaaS \u002F multi-branch\n- Development uses **free local tools** during initial phase (Laragon, Laravel, Composer, GitHub Free, VS Code)\n\n### 2. Business Vision\n- Every business process must be **traceable and auditable**\n- Every feature must solve a **real operational problem**, not be a cosmetic addition\n- Never build a feature without database and business logic support first\n- Support end-to-end flow: receiving goods → selling → invoicing → reporting\n\n### 3. Engineering Principles\n- Maintain **clean, modular architecture** with clear boundaries\n- Use **Laravel** as the backend framework\n- Separate business logic into **Services**, NOT Controllers\n- Keep **Controllers thin** and high-level\n- Use **Form Requests** for validation\n- Use **Resources** for API responses\n- Use **Policies & Middleware** for authorization\n- Use **Repositories** only when complexity justifies it\n- Build each module **independently** with clear boundaries\n\n### 4. Development Order (CRITICAL)\nFollow this exact order — never skip ahead:\n\n| Phase | Module | Priority |\n|-------|--------|----------|\n| 1 | **Products** | Foundation |\n| 2 | **Stock** | Foundation |\n| 3 | **Purchases** | Operations |\n| 4 | **Sales** | Operations |\n| 5 | **Invoices** | Operations |\n| 6 | **Prescriptions** | Pharmacy-specific |\n| 7 | **Finance** | Accounting |\n| 8 | **Reports** | Analytics |\n| 9 | **Analytics** | Intelligence |\n| 10 | **SaaS Features** | Expansion |\n\n**Hard rule:** Do not start on Phase N+1 until Phase N is complete and tested.\n\n## Database Design Rules\n\n### Schema Principles\n- Design tables according to **real business needs**, not just CRUD\n- Every important table must support `company_id` and `branch_id` when needed\n- Stock must be tracked via `stock_batches` and `stock_movements` tables\n- Financial operations must be **traceable and auditable**\n- Use **soft deletes** when necessary\n- Add **indexes** on frequently used fields: `barcode`, `sku`, `status`, `expiry_date`, `company_id`, `branch_id`\n- Avoid unnecessary duplication in tables\n- Every database schema change must be **well-documented and deliberate**\n\n### Key Tables Structure\n\n```\nproducts\n  - id, name, generic_name, barcode, sku, category_id, manufacturer_id\n  - purchase_price, selling_price, reorder_level, company_id, branch_id\n\nstock_batches\n  - id, product_id, batch_number, expiry_date, quantity, purchase_price\n  - company_id, branch_id, warehouse_id\n\nstock_movements\n  - id, product_id, batch_id, type (in\u002Fout\u002Fadjustment), quantity, reference_type\n  - reference_id, notes, company_id, branch_id, user_id\n\npurchases \u002F purchase_orders\n  - id, supplier_id, status (pending\u002Freceived\u002Fpartial\u002Fcanceled)\n  - total_amount, paid_amount, company_id, branch_id\n\npurchase_items\n  - id, purchase_id, product_id, batch_id, quantity, unit_price, total\n\nsales \u002F invoices\n  - id, customer_id, prescription_id, subtotal, discount, tax, total\n  - payment_status, payment_method, company_id, branch_id\n\ninvoice_items\n  - id, invoice_id, product_id, batch_id, quantity, unit_price, total\n\nprescriptions\n  - id, patient_id, doctor_id, prescription_date, notes, status\n\nprescription_items\n  - id, prescription_id, product_id, dosage, quantity, instructions\n\nfinancial_transactions\n  - id, type (revenue\u002Fexpense), amount, reference_type, reference_id\n  - description, company_id, branch_id, user_id\n\nsuppliers \u002F customers \u002F patients \u002F doctors\n  - Standard entity tables with company_id\u002Fbranch_id support\n```\n\n## Stock Management Rules\n\n- Stock must **always reflect real movement**\n- Sales must **automatically decrease** stock\n- Purchases must **automatically increase** stock\n- Returns must **restore stock** correctly\n- **Batch number and expiry date** must always be tracked\n- Use **FEFO (First Expiry, First Out)** for dispensing\u002Fselling medications\n- **Negative stock is NOT allowed** except in special justified cases\n- Every stock change must be recorded in `stock_movements` log\n- Support **low stock alerts** and **near-expiry alerts**\n- Stock quantities are tied to specific branches\u002Fwarehouses\n\n### FEFO Implementation Pattern\n```php\n\u002F\u002F When picking stock for sale\u002Fdispensing:\n\u002F\u002F 1. Filter available batches with quantity > 0\n\u002F\u002F 2. Order by expiry_date ASC\n\u002F\u002F 3. Pick from the soonest-expiring batch first\n\n$batches = StockBatch::where('product_id', $productId)\n    ->where('quantity', '>', 0)\n    ->where('expiry_date', '>=', now())\n    ->orderBy('expiry_date', 'asc')\n    ->get();\n```\n\n## Purchase Management Rules\n\n- Purchases must link to **suppliers, batches, and stock**\n- Every purchase must update stock **upon receipt**\n- Support **Purchase Orders (PO)** and **Goods Received Notes (GRN)**\n- Track **supplier payments** and running balance\n- PO statuses: `pending`, `received`, `partial`, `canceled`\n- Partial receipts must be supported (some items received, others pending)\n\n## Sales & Invoice Rules\n\n- Every invoice must link to **real products and stock batches**\n- Sales must be **auditable** and reversible via returns\n- Handle **discounts, taxes, and payment status** correctly\n- Record **payment methods** for reconciliation\n- Invoice items must link to a real product and stock batch\n- Returns must **correctly reverse** both financial and stock impact\n\n## Prescription Management Rules\n\n- Products must support: name, generic name, barcode, SKU, category, manufacturer, price\n- Support **prescriptions, patients, and doctors**\n- Prescription items must link to **real products**\n- Dispensing\u002Fsales based on prescription must be **traceable**\n- Always respect: **expiry date, batch number, and stock availability**\n\n## Financial Management Rules\n\n- All financial entries must be **accurate and auditable**\n- Support **revenue, expenses, and general ledger**\n- Sales, purchases, returns, and payments must appear in appropriate financial reports\n- **Cash and payment tracking** must be organized and maintainable\n- System must support basic **Profit & Loss (P&L) reports**\n\n## Reports Rules\n\n- Reports must be **useful for management and operations**\n- Support: sales reports, stock reports, purchase reports, financial reports\n- Support **export to Excel and PDF** where possible\n- Reports must be based on **reliable, aggregated data**\n- Reports must respect **company and branch scope**\n\n## Security Rules\n\n- Never expose **sensitive data** via API or UI\n- Every incoming request must be **validated**\n- Every protected action must go through **authentication and authorization**\n- **Never trust client-side data**\n- Never store passwords in plain text\n- Protect endpoints and admin areas with **proper permissions**\n- Use Laravel's built-in authorization (Policies + Gates + Middleware)\n\n## Code Quality Rules\n\n- Write **clean, readable, maintainable code**\n- Use clear names for: classes, methods, variables, migrations, tables\n- Keep methods **small and focused** (single responsibility)\n- Follow **Laravel conventions** strictly\n- NEVER put business logic inside Controllers\n- Use **Services** for workflows, **Models** for data relationships\n- Small, testable changes > large, risky changes\n- Add comments **only when necessary** (code should be self-documenting)\n\n### Service Layer Pattern (MUST FOLLOW)\n\n```php\n\u002F\u002F ❌ BAD - Logic in Controller\nclass ProductController extends Controller\n{\n    public function store(Request $request)\n    {\n        \u002F\u002F validation, business logic, stock creation, response formatting\n        \u002F\u002F ALL in one place - DO NOT DO THIS\n    }\n}\n\n\u002F\u002F ✅ GOOD - Thin Controller\nclass ProductController extends Controller\n{\n    public function store(StoreProductRequest $request, ProductService $service)\n    {\n        $result = $service->create($request->validated());\n        return new ProductResource($result);\n    }\n}\n```\n\n## Testing Rules\n\n- Test **core operations** before adding new features\n- Minimum coverage: stock movement, sales, purchase receipt, returns, invoice creation\n- Add **feature tests** for important workflows\n- Prefer testing **real behavior** over mock-heavy tests\n- Keep tests **simple and reliable**\n- Every important module must have: `Unit tests for Services`, `Feature tests for API endpoints`\n\n### Minimum Test Scenarios\n\n```php\n\u002F\u002F Stock Movement Test\npublic function test_sale_decreases_stock()\n{\n    \u002F\u002F Create product with stock batch\n    \u002F\u002F Create sale invoice\n    \u002F\u002F Assert stock decreased correctly\n}\n\n\u002F\u002F Purchase Receipt Test\npublic function test_purchase_increases_stock()\n{\n    \u002F\u002F Create purchase order\n    \u002F\u002F Receive goods\n    \u002F\u002F Assert stock increased\n}\n\n\u002F\u002F Return Test\npublic function test_return_restores_stock()\n{\n    \u002F\u002F Create sale\n    \u002F\u002F Process return\n    \u002F\u002F Assert stock restored\n}\n```\n\n## MVP Strategy\n\n- Build a **usable first version** before adding advanced features\n- Focus first on: **1 company, 1 branch, 1 warehouse**\n- Add multi-branch\u002Fcompany support only after the core flow is stable\n- Do not over-engineer early\n- Keep MVP **practical and useful** for a real pharmacy\n\n## UI Guidelines\n\n- UI must be **simple, fast, and clear**\n- Prioritize usability for: pharmacy owners, cashiers, management, accountants\n- Use a **unified design system** and **responsive interface**\n- Do not start building complex UI until the **workflow is clear**\n- Support Arabic\u002FRTL layout where appropriate\n\n## Documentation Rules\n\n- Update documentation when **any feature changes**\n- Use clear names for migrations, modules, and services\n- Document important business rules in docs or comments\n- Keep setup\u002Finstallation instructions **simple and clear**\n\n## What to AVOID (Hard Rules)\n\n| Avoid | Why |\n|-------|-----|\n| Starting with UI before logic is clear | Wastes effort on unstable foundations |\n| Building features without database support | Creates untracked, inconsistent data |\n| Business logic in Controllers | Violates separation of concerns, untestable |\n| Ignoring stock\u002Fsales integrity | Breaks audit trail, loses money |\n| Duplicate modules or inconsistent names | Creates confusion, maintenance nightmare |\n| Adding complexity before core flow works | Increases risk, delays delivery |\n| Ignoring traceability and audit | Makes debugging and reconciliation impossible |\n\n## Release Readiness Checklist\n\nBefore saying the project is ready, verify:\n\n- [ ] **Database** - Clear and complete schema with proper indexes\n- [ ] **Products** - Full product management with barcode\u002FSKU\u002Fcategory\u002Fmanufacturer\n- [ ] **Stock** - Complete stock management with batches, expiry, FEFO, alerts\n- [ ] **Purchases** - Full purchase workflow with PO, GRN, supplier management\n- [ ] **Sales & Invoices** - POS, invoicing, returns, payment tracking\n- [ ] **Prescriptions** - Doctor\u002Fpatient management, prescription tracking\n- [ ] **Finance** - Revenue, expenses, P&L reports\n- [ ] **Reports** - Sales, stock, purchase, financial reports with export\n- [ ] **Permissions & Security** - Proper authentication, authorization, role management\n- [ ] **Tests** - Basic test coverage for core workflows\n- [ ] **Documentation** - Simple operational docs and setup instructions\n- [ ] **Expandability** - Architecture supports future multi-branch\u002FSaaS expansion\n\n## Rules for AI Agents\n\nWhen generating code for this project, ALWAYS follow these rules in priority order:\n\n### Priority 1: Database First\n- Always design\u002Fcheck migrations before writing any business logic\n- Always check if the table has `company_id` and `branch_id` support\n- Always add proper indexes on frequently queried columns\n\n### Priority 2: Service Layer\n- Create a Service class for every module's business logic\n- Controllers should only: validate input, call service, return response\n- Services should handle: business rules, workflows, data persistence\n\n### Priority 3: Audit Trail\n- All stock movements must be logged in `stock_movements`\n- All financial transactions must be traceable\n- Never delete records that are part of financial\u002Fstock audit trail (use soft deletes)\n\n### Priority 4: Follow Laravel Conventions\n- PSR-4 autoloading\n- Laravel naming conventions (snake_case tables, CamelCase classes)\n- Resource controllers for RESTful APIs\n- Eloquent relationships for data modeling\n- Form Request classes for validation\n\n### Priority 5: Keep It Simple\n- Don't add complexity before the basic flow works\n- Don't use packages\u002Fmodules that aren't strictly necessary\n- Don't build for multi-branch until single-branch is stable\n\n## Module Development Template\n\nWhen creating a new module, follow this structure:\n\n```\napp\u002FModules\u002F{ModuleName}\u002F\n├── Controllers\u002F\n│   └── {ModuleName}Controller.php       # Thin controller\n├── Models\u002F\n│   └── {ModuleName}.php                 # Eloquent model\n├── Services\u002F\n│   └── {ModuleName}Service.php          # Business logic\n├── Requests\u002F\n│   └── Store{ModuleName}Request.php     # Validation\n├── Resources\u002F\n│   └── {ModuleName}Resource.php         # API response\n├── Policies\u002F\n│   └── {ModuleName}Policy.php           # Authorization\n└── routes\u002F\n    └── api.php                          # API routes\n```\n\n### Example: Product Module\n\n```php\n\u002F\u002F app\u002FModules\u002FProducts\u002FControllers\u002FProductController.php\nnamespace App\\Modules\\Products\\Controllers;\n\nuse App\\Http\\Controllers\\Controller;\nuse App\\Modules\\Products\\Requests\\StoreProductRequest;\nuse App\\Modules\\Products\\Resources\\ProductResource;\nuse App\\Modules\\Products\\Services\\ProductService;\n\nclass ProductController extends Controller\n{\n    public function __construct(\n        private readonly ProductService $productService\n    ) {}\n\n    public function store(StoreProductRequest $request): ProductResource\n    {\n        $product = $this->productService->create($request->validated());\n        return new ProductResource($product);\n    }\n\n    public function index(): ProductResource\n    {\n        $products = $this->productService->list();\n        return ProductResource::collection($products);\n    }\n\n    public function show(int $id): ProductResource\n    {\n        $product = $this->productService->findOrFail($id);\n        return new ProductResource($product);\n    }\n\n    public function update(UpdateProductRequest $request, int $id): ProductResource\n    {\n        $product = $this->productService->update($id, $request->validated());\n        return new ProductResource($product);\n    }\n\n    public function destroy(int $id): JsonResponse\n    {\n        $this->productService->delete($id);\n        return response()->json(['message' => 'Product deleted successfully']);\n    }\n}\n```\n\n## Final Instruction\n\nWhen working on Z-Syst Pharmacy:\n1. **Start from the database** - Design schema first\n2. **Follow the development order** - Products → Stock → Purchases → Sales → Invoices → Prescriptions → Finance → Reports → SaaS\n3. **Keep business logic in Services** - NOT Controllers\n4. **Ensure every operation is traceable** - Stock movements, financial transactions\n5. **Test core workflows** - Stock change, sale, purchase receipt, return\n6. **Keep it simple** - Don't over-engineer, build for a real pharmacy first\n7. **Follow Laravel conventions** - Naming, structure, patterns\n8. **Document what matters** - Business rules, schema changes, important decisions\n","# Z-Syst Pharmacy Management System\n\nComprehensive development rules for building a professional pharmacy management system (PharmaMaster Pro) using Laravel. This skill ensures systematic, production-ready development following clean architecture, domain-driven design, and pharmacy-specific business logic.\n\n## When to Use This Skill\n\nUse this skill when working on **any aspect of a pharmacy management system**, including:\n\n| Module | When to Activate |\n|--------|-----------------|\n| **Products** | Creating\u002Fmanaging medications, inventory items, barcodes, SKUs, categories, manufacturers, pricing |\n| **Stock** | Implementing inventory tracking, stock batches, movements, FEFO, expiry alerts, low-stock warnings |\n| **Purchases** | Building purchase orders, GRN (Goods Received Notes), supplier management, payment tracking |\n| **Sales & Invoices** | Creating POS, invoices, returns\u002Frefunds, payment methods, discounts, taxes |\n| **Prescriptions** | Managing doctors, patients, prescription items, digital scrips, refills |\n| **Finance** | Implementing revenue\u002Fexpense tracking, general ledger, profit\u002Floss reports |\n| **Reports** | Generating sales reports, stock reports, purchase reports, financial statements |\n| **SaaS Features** | Multi-company, multi-branch, multi-warehouse support, subscription management |\n\nSkip this skill for: non-pharmacy projects, generic CRUD apps, learning\u002Ftutorial code, or projects not using Laravel.\n\n## Core Principles\n\n### 1. Ultimate Goal\n- Build a **professional pharmacy system** ready for real-world use\n- Strong management of: Products, Stock, Purchases, Sales, Prescriptions, Finance, and Reports\n- Suitable for a real pharmacy first, then expandable to SaaS \u002F multi-branch\n- Development uses **free local tools** during initial phase (Laragon, Laravel, Composer, GitHub Free, VS Code)\n\n### 2. Business Vision\n- Every business process must be **traceable and auditable**\n- Every feature must solve a **real operational problem**, not be a cosmetic addition\n- Never build a feature without database and business logic support first\n- Support end-to-end flow: receiving goods → selling → invoicing → reporting\n\n### 3. Engineering Principles\n- Maintain **clean, modular architecture** with clear boundaries\n- Use **Laravel** as the backend framework\n- Separate business logic into **Services**, NOT Controllers\n- Keep **Controllers thin** and high-level\n- Use **Form Requests** for validation\n- Use **Resources** for API responses\n- Use **Policies & Middleware** for authorization\n- Use **Repositories** only when complexity justifies it\n- Build each module **independently** with clear boundaries\n\n### 4. Development Order (CRITICAL)\nFollow this exact order — never skip ahead:\n\n| Phase | Module | Priority |\n|-------|--------|----------|\n| 1 | **Products** | Foundation |\n| 2 | **Stock** | Foundation |\n| 3 | **Purchases** | Operations |\n| 4 | **Sales** | Operations |\n| 5 | **Invoices** | Operations |\n| 6 | **Prescriptions** | Pharmacy-specific |\n| 7 | **Finance** | Accounting |\n| 8 | **Reports** | Analytics |\n| 9 | **Analytics** | Intelligence |\n| 10 | **SaaS Features** | Expansion |\n\n**Hard rule:** Do not start on Phase N+1 until Phase N is complete and tested.\n\n## Database Design Rules\n\n### Schema Principles\n- Design tables according to **real business needs**, not just CRUD\n- Every important table must support `company_id` and `branch_id` when needed\n- Stock must be tracked via `stock_batches` and `stock_movements` tables\n- Financial operations must be **traceable and auditable**\n- Use **soft deletes** when necessary\n- Add **indexes** on frequently used fields: `barcode`, `sku`, `status`, `expiry_date`, `company_id`, `branch_id`\n- Avoid unnecessary duplication in tables\n- Every database schema change must be **well-documented and deliberate**\n\n### Key Tables Structure\n\n```\nproducts\n  - id, name, generic_name, barcode, sku, category_id, manufacturer_id\n  - purchase_price, selling_price, reorder_level, company_id, branch_id\n\nstock_batches\n  - id, product_id, batch_number, expiry_date, quantity, purchase_price\n  - company_id, branch_id, warehouse_id\n\nstock_movements\n  - id, product_id, batch_id, type (in\u002Fout\u002Fadjustment), quantity, reference_type\n  - reference_id, notes, company_id, branch_id, user_id\n\npurchases \u002F purchase_orders\n  - id, supplier_id, status (pending\u002Freceived\u002Fpartial\u002Fcanceled)\n  - total_amount, paid_amount, company_id, branch_id\n\npurchase_items\n  - id, purchase_id, product_id, batch_id, quantity, unit_price, total\n\nsales \u002F invoices\n  - id, customer_id, prescription_id, subtotal, discount, tax, total\n  - payment_status, payment_method, company_id, branch_id\n\ninvoice_items\n  - id, invoice_id, product_id, batch_id, quantity, unit_price, total\n\nprescriptions\n  - id, patient_id, doctor_id, prescription_date, notes, status\n\nprescription_items\n  - id, prescription_id, product_id, dosage, quantity, instructions\n\nfinancial_transactions\n  - id, type (revenue\u002Fexpense), amount, reference_type, reference_id\n  - description, company_id, branch_id, user_id\n\nsuppliers \u002F customers \u002F patients \u002F doctors\n  - Standard entity tables with company_id\u002Fbranch_id support\n```\n\n## Stock Management Rules\n\n- Stock must **always reflect real movement**\n- Sales must **automatically decrease** stock\n- Purchases must **automatically increase** stock\n- Returns must **restore stock** correctly\n- **Batch number and expiry date** must always be tracked\n- Use **FEFO (First Expiry, First Out)** for dispensing\u002Fselling medications\n- **Negative stock is NOT allowed** except in special justified cases\n- Every stock change must be recorded in `stock_movements` log\n- Support **low stock alerts** and **near-expiry alerts**\n- Stock quantities are tied to specific branches\u002Fwarehouses\n\n### FEFO Implementation Pattern\n```php\n\u002F\u002F When picking stock for sale\u002Fdispensing:\n\u002F\u002F 1. Filter available batches with quantity > 0\n\u002F\u002F 2. Order by expiry_date ASC\n\u002F\u002F 3. Pick from the soonest-expiring batch first\n\n$batches = StockBatch::where('product_id', $productId)\n    ->where('quantity', '>', 0)\n    ->where('expiry_date', '>=', now())\n    ->orderBy('expiry_date', 'asc')\n    ->get();\n```\n\n## Purchase Management Rules\n\n- Purchases must link to **suppliers, batches, and stock**\n- Every purchase must update stock **upon receipt**\n- Support **Purchase Orders (PO)** and **Goods Received Notes (GRN)**\n- Track **supplier payments** and running balance\n- PO statuses: `pending`, `received`, `partial`, `canceled`\n- Partial receipts must be supported (some items received, others pending)\n\n## Sales & Invoice Rules\n\n- Every invoice must link to **real products and stock batches**\n- Sales must be **auditable** and reversible via returns\n- Handle **discounts, taxes, and payment status** correctly\n- Record **payment methods** for reconciliation\n- Invoice items must link to a real product and stock batch\n- Returns must **correctly reverse** both financial and stock impact\n\n## Prescription Management Rules\n\n- Products must support: name, generic name, barcode, SKU, category, manufacturer, price\n- Support **prescriptions, patients, and doctors**\n- Prescription items must link to **real products**\n- Dispensing\u002Fsales based on prescription must be **traceable**\n- Always respect: **expiry date, batch number, and stock availability**\n\n## Financial Management Rules\n\n- All financial entries must be **accurate and auditable**\n- Support **revenue, expenses, and general ledger**\n- Sales, purchases, returns, and payments must appear in appropriate financial reports\n- **Cash and payment tracking** must be organized and maintainable\n- System must support basic **Profit & Loss (P&L) reports**\n\n## Reports Rules\n\n- Reports must be **useful for management and operations**\n- Support: sales reports, stock reports, purchase reports, financial reports\n- Support **export to Excel and PDF** where possible\n- Reports must be based on **reliable, aggregated data**\n- Reports must respect **company and branch scope**\n\n## Security Rules\n\n- Never expose **sensitive data** via API or UI\n- Every incoming request must be **validated**\n- Every protected action must go through **authentication and authorization**\n- **Never trust client-side data**\n- Never store passwords in plain text\n- Protect endpoints and admin areas with **proper permissions**\n- Use Laravel's built-in authorization (Policies + Gates + Middleware)\n\n## Code Quality Rules\n\n- Write **clean, readable, maintainable code**\n- Use clear names for: classes, methods, variables, migrations, tables\n- Keep methods **small and focused** (single responsibility)\n- Follow **Laravel conventions** strictly\n- NEVER put business logic inside Controllers\n- Use **Services** for workflows, **Models** for data relationships\n- Small, testable changes > large, risky changes\n- Add comments **only when necessary** (code should be self-documenting)\n\n### Service Layer Pattern (MUST FOLLOW)\n\n```php\n\u002F\u002F ❌ BAD - Logic in Controller\nclass ProductController extends Controller\n{\n    public function store(Request $request)\n    {\n        \u002F\u002F validation, business logic, stock creation, response formatting\n        \u002F\u002F ALL in one place - DO NOT DO THIS\n    }\n}\n\n\u002F\u002F ✅ GOOD - Thin Controller\nclass ProductController extends Controller\n{\n    public function store(StoreProductRequest $request, ProductService $service)\n    {\n        $result = $service->create($request->validated());\n        return new ProductResource($result);\n    }\n}\n```\n\n## Testing Rules\n\n- Test **core operations** before adding new features\n- Minimum coverage: stock movement, sales, purchase receipt, returns, invoice creation\n- Add **feature tests** for important workflows\n- Prefer testing **real behavior** over mock-heavy tests\n- Keep tests **simple and reliable**\n- Every important module must have: `Unit tests for Services`, `Feature tests for API endpoints`\n\n### Minimum Test Scenarios\n\n```php\n\u002F\u002F Stock Movement Test\npublic function test_sale_decreases_stock()\n{\n    \u002F\u002F Create product with stock batch\n    \u002F\u002F Create sale invoice\n    \u002F\u002F Assert stock decreased correctly\n}\n\n\u002F\u002F Purchase Receipt Test\npublic function test_purchase_increases_stock()\n{\n    \u002F\u002F Create purchase order\n    \u002F\u002F Receive goods\n    \u002F\u002F Assert stock increased\n}\n\n\u002F\u002F Return Test\npublic function test_return_restores_stock()\n{\n    \u002F\u002F Create sale\n    \u002F\u002F Process return\n    \u002F\u002F Assert stock restored\n}\n```\n\n## MVP Strategy\n\n- Build a **usable first version** before adding advanced features\n- Focus first on: **1 company, 1 branch, 1 warehouse**\n- Add multi-branch\u002Fcompany support only after the core flow is stable\n- Do not over-engineer early\n- Keep MVP **practical and useful** for a real pharmacy\n\n## UI Guidelines\n\n- UI must be **simple, fast, and clear**\n- Prioritize usability for: pharmacy owners, cashiers, management, accountants\n- Use a **unified design system** and **responsive interface**\n- Do not start building complex UI until the **workflow is clear**\n- Support Arabic\u002FRTL layout where appropriate\n\n## Documentation Rules\n\n- Update documentation when **any feature changes**\n- Use clear names for migrations, modules, and services\n- Document important business rules in docs or comments\n- Keep setup\u002Finstallation instructions **simple and clear**\n\n## What to AVOID (Hard Rules)\n\n| Avoid | Why |\n|-------|-----|\n| Starting with UI before logic is clear | Wastes effort on unstable foundations |\n| Building features without database support | Creates untracked, inconsistent data |\n| Business logic in Controllers | Violates separation of concerns, untestable |\n| Ignoring stock\u002Fsales integrity | Breaks audit trail, loses money |\n| Duplicate modules or inconsistent names | Creates confusion, maintenance nightmare |\n| Adding complexity before core flow works | Increases risk, delays delivery |\n| Ignoring traceability and audit | Makes debugging and reconciliation impossible |\n\n## Release Readiness Checklist\n\nBefore saying the project is ready, verify:\n\n- [ ] **Database** - Clear and complete schema with proper indexes\n- [ ] **Products** - Full product management with barcode\u002FSKU\u002Fcategory\u002Fmanufacturer\n- [ ] **Stock** - Complete stock management with batches, expiry, FEFO, alerts\n- [ ] **Purchases** - Full purchase workflow with PO, GRN, supplier management\n- [ ] **Sales & Invoices** - POS, invoicing, returns, payment tracking\n- [ ] **Prescriptions** - Doctor\u002Fpatient management, prescription tracking\n- [ ] **Finance** - Revenue, expenses, P&L reports\n- [ ] **Reports** - Sales, stock, purchase, financial reports with export\n- [ ] **Permissions & Security** - Proper authentication, authorization, role management\n- [ ] **Tests** - Basic test coverage for core workflows\n- [ ] **Documentation** - Simple operational docs and setup instructions\n- [ ] **Expandability** - Architecture supports future multi-branch\u002FSaaS expansion\n\n## Rules for AI Agents\n\nWhen generating code for this project, ALWAYS follow these rules in priority order:\n\n### Priority 1: Database First\n- Always design\u002Fcheck migrations before writing any business logic\n- Always check if the table has `company_id` and `branch_id` support\n- Always add proper indexes on frequently queried columns\n\n### Priority 2: Service Layer\n- Create a Service class for every module's business logic\n- Controllers should only: validate input, call service, return response\n- Services should handle: business rules, workflows, data persistence\n\n### Priority 3: Audit Trail\n- All stock movements must be logged in `stock_movements`\n- All financial transactions must be traceable\n- Never delete records that are part of financial\u002Fstock audit trail (use soft deletes)\n\n### Priority 4: Follow Laravel Conventions\n- PSR-4 autoloading\n- Laravel naming conventions (snake_case tables, CamelCase classes)\n- Resource controllers for RESTful APIs\n- Eloquent relationships for data modeling\n- Form Request classes for validation\n\n### Priority 5: Keep It Simple\n- Don't add complexity before the basic flow works\n- Don't use packages\u002Fmodules that aren't strictly necessary\n- Don't build for multi-branch until single-branch is stable\n\n## Module Development Template\n\nWhen creating a new module, follow this structure:\n\n```\napp\u002FModules\u002F{ModuleName}\u002F\n├── Controllers\u002F\n│   └── {ModuleName}Controller.php       # Thin controller\n├── Models\u002F\n│   └── {ModuleName}.php                 # Eloquent model\n├── Services\u002F\n│   └── {ModuleName}Service.php          # Business logic\n├── Requests\u002F\n│   └── Store{ModuleName}Request.php     # Validation\n├── Resources\u002F\n│   └── {ModuleName}Resource.php         # API response\n├── Policies\u002F\n│   └── {ModuleName}Policy.php           # Authorization\n└── routes\u002F\n    └── api.php                          # API routes\n```\n\n### Example: Product Module\n\n```php\n\u002F\u002F app\u002FModules\u002FProducts\u002FControllers\u002FProductController.php\nnamespace App\\Modules\\Products\\Controllers;\n\nuse App\\Http\\Controllers\\Controller;\nuse App\\Modules\\Products\\Requests\\StoreProductRequest;\nuse App\\Modules\\Products\\Resources\\ProductResource;\nuse App\\Modules\\Products\\Services\\ProductService;\n\nclass ProductController extends Controller\n{\n    public function __construct(\n        private readonly ProductService $productService\n    ) {}\n\n    public function store(StoreProductRequest $request): ProductResource\n    {\n        $product = $this->productService->create($request->validated());\n        return new ProductResource($product);\n    }\n\n    public function index(): ProductResource\n    {\n        $products = $this->productService->list();\n        return ProductResource::collection($products);\n    }\n\n    public function show(int $id): ProductResource\n    {\n        $product = $this->productService->findOrFail($id);\n        return new ProductResource($product);\n    }\n\n    public function update(UpdateProductRequest $request, int $id): ProductResource\n    {\n        $product = $this->productService->update($id, $request->validated());\n        return new ProductResource($product);\n    }\n\n    public function destroy(int $id): JsonResponse\n    {\n        $this->productService->delete($id);\n        return response()->json(['message' => 'Product deleted successfully']);\n    }\n}\n```\n\n## Final Instruction\n\nWhen working on Z-Syst Pharmacy:\n1. **Start from the database** - Design schema first\n2. **Follow the development order** - Products → Stock → Purchases → Sales → Invoices → Prescriptions → Finance → Reports → SaaS\n3. **Keep business logic in Services** - NOT Controllers\n4. **Ensure every operation is traceable** - Stock movements, financial transactions\n5. **Test core workflows** - Stock change, sale, purchase receipt, return\n6. **Keep it simple** - Don't over-engineer, build for a real pharmacy first\n7. **Follow Laravel conventions** - Naming, structure, patterns\n8. **Document what matters** - Business rules, schema changes, important decisions\n",{"name":5,"description":7},"main","f4a94d0fb721a5e4f4f937d814f0a296a9e35565",".agents\u002Fskills\u002Fz-syst-pharmacy",1,"https:\u002F\u002Fgithub.com\u002Fzyadgfh\u002FZ-Syst","https:\u002F\u002Fgithub.com\u002Fzyadgfh","2026-11-15 00:23:38",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add zyadgfh\u002FZ-Syst --skill Z-Syst",{"tool":37,"command":38},"bunx","bunx skills add zyadgfh\u002FZ-Syst --skill Z-Syst",{"tool":40,"command":41},"pnpm","pnpm dlx skills add zyadgfh\u002FZ-Syst --skill Z-Syst","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fzyadgfh\u002FZ-Syst\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fz-syst-pharmacy\u002FSKILL.md",true,[],[46,53,60,68,75,81],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M7ADYDYBCSZFRC5ZBQCZC9Z0","supabase","Use when doing ANY task involving Supabase. Triggers: Supabase products (Database, Auth, Edge Functions, Realtime, Storage, Vectors, Cron, Queues); client libraries and SSR integrations (supabase-js, @supabase\u002Fssr) in Next.js, React, SvelteKit, Astro, Remix; auth issues (login, logout, sessions, JWT, cookies, getSession, getUser, getClaims, RLS); Supabase CLI or MCP server; schema changes, migrations, declarative schemas, security audits, Postgres extensions (pg_graphql, pg_cron, pg_vector); debugging and troubleshooting errors or unexpected behavior on Supabase projects (HTTP errors, Postgres errors, RLS surprises, permission denied, schema cache issues, timeouts, Edge Function crashes, Realtime drops, Storage failures) and reading or querying logs (Logs Explorer, ClickHouse).","https:\u002F\u002Fgithub.com\u002Fzyadgfh\u002FZ-Syst\u002Fblob\u002Fmain\u002Fagent\u002Fskills\u002Fsupabase\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7ADY1YMGRXW9GZYC4TS4NGY","supabase-postgres-best-practices","Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pg_cron, pgmq), vector\u002Fsemantic search (pgvector), and restoring dumps (pg_restore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.","https:\u002F\u002Fgithub.com\u002Fzyadgfh\u002FZ-Syst\u002Fblob\u002Fmain\u002Fagent\u002Fskills\u002Fsupabase-postgres-best-practices\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":64,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M7ADXNAA4JTVTNRV7EHJX2W4","backend-patterns","Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.","https:\u002F\u002Fgithub.com\u002Fzyadgfh\u002FZ-Syst\u002Fblob\u002Fmain\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fzyadgfh\u002FZ-Syst\u002Fblob\u002Fmain\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M7ADXBNGSAKY4TXH96Y5MCMF","code-vulnscan","Use this when the user wants to find security vulnerabilities in a codebase, perform a security audit, scan for CVEs, detect secrets, review React\u002FNext.js or Go services, audit architecture\u002Fapplication\u002Finfrastructure flaws, review auth\u002FAPI\u002Fcrypto\u002Fbusiness logic, check IaC\u002Fcloud\u002Fruntime configs, or generate a vulnerability report. Performs taint-flow, control-flow, architecture, and exploitability analysis across Python, JS\u002FTS, Java, Go, PHP, Ruby, C\u002FC++, C#, Rust, and infrastructure.","https:\u002F\u002Fgithub.com\u002Fzyadgfh\u002FZ-Syst\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fcode-vulnscan\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7ADX5Q4HEA774P07HFJZVYD","z-syst-pharmacy","https:\u002F\u002Fgithub.com\u002Fzyadgfh\u002FZ-Syst\u002Fblob\u002Fmain\u002F.blackbox\u002Fskills\u002Fz-syst-pharmacy\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7ADX30C4C1T49R63PVH35MZ","ui-ux-promax","Brief description of what this Skill does and when to use it","https:\u002F\u002Fgithub.com\u002Fzyadgfh\u002FZ-Syst\u002Fblob\u002Fmain\u002F.blackbox\u002Fskills\u002Fui-ux-promax\u002FSKILL.md",[],[]]