Community研究與資料分析github.com

kos322/testrail-skill

AI 代理技能,用於 TestRail REST API - 零依賴,比 MCP 伺服器更安全的替代方案

testrail-skill 是什麼?

此技能讓 AI 代理(如 Claude Code、Cursor、Codex 等)能直接透過本地 bash 包裝器與 TestRail REST API 互動,無需任何額外套件,從而提升安全性並降低依賴。使用者只需設定 `TESTRAIL_URL`、`TESTRAIL_USER` 和 `TESTRAIL_API_KEY` 三個環境變數即可快速上手。技能內建決策樹引導代理選擇最佳腳本:若已知專案 ID 且為唯讀查詢,可直接呼叫對應包裝器;若未知專案 ID,則先執行 `get_projects.sh` 探索可存取專案;遇到設定或認證問題時則執行 `doctor.sh` 進行診斷。輸出合約明確定義各指令的回傳格式,例如 `count_cases.sh` 回傳純整數,`list_cases.sh` 回傳純文字或 JSON,確保代理能預期並解析結果。此外也支援 Windows 環境(Git Bash 或 WSL),並提供 PowerShell 包裝器以利整合。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add kos322/testrail-skill

Installed? Explore more 研究與資料分析 skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

TestRail API 技能

透過存放庫本地的 bash 包裝器直接整合 TestRail REST API。

安裝

首先複製存放庫:

git clone https://github.com/kos322/testrail-skill.git
cd testrail-skill

設定

設定以下環境變數:

  • TESTRAIL_URL
  • TESTRAIL_USER
  • TESTRAIL_API_KEY

基礎 URL:

${TESTRAIL_URL}/index.php?/api/v2

決策樹

  • 已知 PROJECT_ID + 簡單唯讀問題: 直接呼叫對應的包裝器。
  • 未知 PROJECT_ID: 呼叫 ./scripts/get_projects.sh。
  • 環境/認證/設定問題或首次安裝: 呼叫 ./scripts/doctor.sh。

常見查詢

# 已知專案 ID:取得案例總數
./scripts/count_cases.sh PROJECT_ID [SECTION_ID] [--suite SUITE_ID]

# 已知專案 ID:取得完整案例列表(自動分頁)
./scripts/list_cases.sh PROJECT_ID [SECTION_ID] [--suite SUITE_ID]

# 已知專案 ID:取得原始分頁案例回應
./scripts/get_cases.sh PROJECT_ID [SECTION_ID] [--suite SUITE_ID]

# 任何時候:讀取單一案例
./scripts/get_case.sh CASE_ID | jq -r .title

# 單一欄位,無需手動解析 JSON
./scripts/get_case_field.sh CASE_ID FIELD

# 前置條件捷徑
./scripts/get_case_precondition.sh CASE_ID

# 未知專案 ID:探索可存取的專案
./scripts/get_projects.sh | jq '(.projects // .) | map({id, name})'

# 設定/認證問題:驗證環境與存取權限
./scripts/doctor.sh

偏好的包裝器

  • scripts/count_cases.sh — 可靠的案例總數
  • scripts/list_cases.sh — 完整案例列表(自動分頁)
  • scripts/get_cases.sh — 原始分頁案例回應
  • scripts/get_case.sh — 單一案例查詢
  • scripts/get_case_field.sh — 單一欄位查詢
  • scripts/get_case_precondition.sh — 前置條件捷徑
  • scripts/get_projects.sh — 探索可存取的專案
  • scripts/doctor.sh — 設定/認證快速檢查
  • scripts/create_run.sh, scripts/add_result*.sh, scripts/close_run.sh — 測試執行/結果流程
  • scripts/get_reference_data.sh — 狀態、欄位、模板、使用者

輸出合約

用途指令輸出格式
案例總數count-cases純整數
案例列表list-cases預設為純文字:C{id}: {title}
結構化案例列表list-cases --format jsonJSON 物件,包含 count 和 cases
單一案例get-caseJSON 案例物件
單一案例欄位get-case-field純量/字串,或陣列/物件的簡潔 JSON
案例前置條件get-case-precondition純文字 / 原始欄位值

分頁

  • get_cases、get_runs、get_results* 等端點可能會有分頁。
  • 不要預設 .size 就是安全的總數,除非 _links.next 為空。
  • 若問題是「有多少案例?」,請使用 ./scripts/count_cases.sh。

Windows

  • 建議:Git Bash / WSL。
  • 僅限 PowerShell 的環境:使用 powershell/ 目錄下的簡化包裝器。
  • PowerShell 包裝器只會啟動 bash 腳本,不會自行讀取 .env。
.\powershell\count-cases.ps1 1
.\powershell\list-cases.ps1 1
.\powershell\list-cases.ps1 1 --format json
.\powershell\get-case.ps1 93
.\powershell\get-case-field.ps1 2 custom_preconds
.\powershell\get-case-precondition.ps1 2
.\powershell\get-cases.ps1 1 10 --suite 1
.\powershell\get-sections.ps1 1 1
.\powershell\get-runs.ps1 1

隨需文件

  • scripts/README.md — 各腳本的使用說明
  • docs/api-reference.md — 端點說明與請求/回應格式
  • docs/troubleshooting.md — 設定與認證失敗的疑難排解
  • docs/agent-guide.md — 代理專用的執行指引
  • docs/maintenance/endpoint-status.md — 維護狀態快照,非執行階段指引

範例

  • examples/workflow_ci.sh
  • examples/workflow_plans_milestones.sh
  • examples/workflow_attachments.sh

官方 API 文件:https://support.testrail.com/hc/en-us/categories/7076541806228-API-Manual

相關技能