Answer questions about the TadReamk ERP system by analysing the query, selecting the right API endpoint(s) from api_doc, and executing them. Use when user asks about ERP data such as "how many employees", "show me leave requests", "what funding sources do we have", "list expenses", or any question that requires reading data from the ERP system.
Analyse the user's question about the TadReamk ERP system, find the right API endpoint(s) to answer it, execute them, and present the result.
The user's query is: $ARGUMENTS
If the query is empty or unclear, ask the user what they want to know about the ERP system.
Auth token is loaded from the WEBAPP_ACCESS_TOKEN variable — first from .env in the current working directory, then from ~/.claude/.env as a global fallback.
API base URL: https://api-erp.tadreamk.com/api/v1
Load the auth token by reading .env in the current working directory and extracting the WEBAPP_ACCESS_TOKEN value. If the variable is missing or empty, try ~/.claude/.env as a fallback. If still missing in both locations, tell the user to set it in either .env (project-level) or ~/.claude/.env (global) and stop.
Read the user's question and determine:
${CLAUDE_PLUGIN_ROOT}/api_doc/To identify the right module(s), scan the index.md file inside the most relevant module directory under ${CLAUDE_PLUGIN_ROOT}/api_doc/. Each index.md has a summary table listing all available endpoints with their HTTP method, path, and description.
Available modules:
articles, bank_accounts, bank_statements, calendar, comments,
company_events, company_roles, contact_directory, customer_management,
customer_requirements, employee_contracts, employees, equipment_management,
exercise_score_instructions, exercises, expense_categories,
expense_management, funding_opportunities, funding_sources,
funding_utilization, guide_pages, guide_quiz, health, hr_ops,
job_application_workflow, job_applications, job_posts, leave_management,
market_research, notifications, onboarding, payslip_workflow,
personal_notes, personal_particular, rachel_ai, reimbursement_workflow,
task_ai_instructions, tasks, technical_reports, templates,
timesheet_workflow, treasury, whitelist
Once you identify the relevant module(s):
index.md from ${CLAUDE_PLUGIN_ROOT}/api_doc/<module>/index.md to see all available endpoints.${CLAUDE_PLUGIN_ROOT}/api_doc/<module>/<endpoint_file>.md to understand the request format, query parameters, and response structure.Important: If the user's question is complex and requires data from multiple endpoints or modules, plan the sequence of API calls. For example:
Execute the selected API endpoint(s) using curl:
curl -s "<API_BASE_URL>/<endpoint_path>?<query_params>" \
-H "Authorization: Bearer <token>"
For POST/PUT/PATCH requests, use a temporary JSON file to avoid shell escaping issues:
curl -s -X <METHOD> "<url>" -H "Authorization: Bearer <token>" -H "Content-Type: application/json" -d @<tmp_file>Iterative execution: If the first API call reveals that additional calls are needed to fully answer the question, make those follow-up calls. For example:
page, limit parameters)Continue until you have enough data to answer the user's question completely.
Format the results clearly for the user:
page and limit parameters and the user wants all results, paginate until done (but cap at a reasonable limit like 500 records).