jpskill.com
🛠️ 開発・MCP コミュニティ 🔴 エンジニア向け 👤 エンジニア・AI開発者

🛠️ CLIBackendテスト

cli-backend-testing

LobeHub CLI を用いて、ローカル開発サーバー上のバックエンドAPI変更を検証する統合テストを効率的に実行するSkill。

⏱ ライブラリ調査+組込 半日 → 1時間

📺 まず動画で見る(YouTube)

▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗

※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。

📜 元の英語説明(参考)

CLI + Backend integration testing workflow. Use when verifying backend API changes (TRPC routers, services, models) via the LobeHub CLI against a local dev server. Triggers on 'cli test', 'test with cli', 'verify with cli', 'local cli test', 'backend test with cli', or when needing to validate server-side changes end-to-end.

🇯🇵 日本人クリエイター向け解説

一言でいうと

LobeHub CLI を用いて、ローカル開発サーバー上のバックエンドAPI変更を検証する統合テストを効率的に実行するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-17
同梱ファイル
1

💬 こう話しかけるだけ — サンプルプロンプト

  • CLI Backend Testing を使って、最小構成のサンプルコードを示して
  • CLI Backend Testing の主な使い方と注意点を教えて
  • CLI Backend Testing を既存プロジェクトに組み込む方法を教えて

これをClaude Code に貼るだけで、このSkillが自動発動します。

📖 Claude が読む原文 SKILL.md(中身を展開)

この本文は AI(Claude)が読むための原文(英語または中国語)です。日本語訳は順次追加中。

CLI + Backend Integration Testing

Standard workflow for verifying backend changes using the LobeHub CLI (lh) against a local dev server.

When to Use

  • Verifying TRPC router / service / model changes end-to-end
  • Testing new API fields or response structure changes
  • Validating CLI command output after backend modifications
  • Debugging data flow issues between server and CLI

Prerequisites

Requirement Details
Dev server localhost:3011 (Next.js)
CLI source lobehub/apps/cli/
CLI dev mode Uses LOBEHUB_CLI_HOME=.lobehub-dev for isolated credentials
Auth Device Code Flow login to local server

Quick Reference

All CLI dev commands run from lobehub/apps/cli/:

# Shorthand for all commands below
CLI="LOBEHUB_CLI_HOME=.lobehub-dev bun src/index.ts"

Workflow

Step 1: Ensure Dev Server is Running

Check if the dev server is already running:

curl -s -o /dev/null -w '%{http_code}' http://localhost:3011/ 2> /dev/null
  • If reachable (returns any HTTP status): server is running. Skip to Step 2.
  • If unreachable: start the server:
# From cloud repo root
pnpm run dev:next

To restart (pick up server-side code changes):

lsof -ti:3011 | xargs kill
pnpm run dev:next

Important: Server-side code changes in the submodule (lobehub/src/server/, lobehub/packages/) require a server restart. Next.js hot-reload may not pick up changes in submodule packages.

Step 2: Check CLI Authentication

Check if dev credentials already exist:

cat lobehub/apps/cli/.lobehub-dev/settings.json 2> /dev/null
  • If file exists and contains "serverUrl": "http://localhost:3011": already authenticated. Skip to Step 3.
  • If file missing or points to wrong server: login is needed. Ask the user to run:
! cd lobehub/apps/cli && LOBEHUB_CLI_HOME=.lobehub-dev bun src/index.ts login --server http://localhost:3011

Login requires interactive browser authorization (OIDC Device Code Flow), so the user must run it themselves via ! prefix. After login, credentials are saved to lobehub/apps/cli/.lobehub-dev/ and persist across sessions.

Step 3: Test with CLI Commands

CLI runs from source (bun src/index.ts), so CLI-side code changes take effect immediately without rebuilding.

cd lobehub/apps/cli
LOBEHUB_CLI_HOME=.lobehub-dev bun src/index.ts <command>

Step 4: Clean Up Test Data

Delete any test data created during verification:

LOBEHUB_CLI_HOME=.lobehub-dev bun src/index.ts task delete < id > -y
LOBEHUB_CLI_HOME=.lobehub-dev bun src/index.ts agent delete < id > -y

Common Testing Patterns

Task System

# List tasks
$CLI task list

# Create test data with nesting
$CLI task create -n "Root Task" -i "Test instruction"
$CLI task create -n "Child Task" -i "Sub instruction" --parent T-1

# View task detail (tests getTaskDetail service)
$CLI task view T-1

# View task tree
$CLI task tree T-1

# Test lifecycle
$CLI task edit T-1 --status running
$CLI task comment T-1 -m "Test comment"

# Clean up
$CLI task delete T-1 -y

Agent System

# List agents
$CLI agent list

# View agent detail
$CLI agent view <agent-id>

# Run agent (tests agent execution pipeline)
$CLI agent run <agent-id> -m "Test prompt"

Document & Knowledge Base

# List documents
$CLI doc list

# Create and view
$CLI doc create -t "Test Doc" -c "Content here"
$CLI doc view <doc-id>

# Knowledge base
$CLI kb list
$CLI kb tree <kb-id>

Model & Provider

# List models and providers
$CLI model list
$CLI provider list

# Test provider connectivity
$CLI provider test <provider-id>

Dev-Test Cycle

The standard cycle for backend development:

1. Make code changes (service/model/router/type)
         |
2. Run unit tests (fast feedback)
   bunx vitest run --silent='passed-only' '<test-file>'
         |
3. Restart dev server (if server-side changes)
   lsof -ti:3011 | xargs kill && pnpm run dev:next
         |
4. CLI verification (end-to-end)
   LOBEHUB_CLI_HOME=.lobehub-dev bun src/index.ts <command>
         |
5. Clean up test data

When Server Restart is Needed

Change Location Restart?
lobehub/src/server/ (routers, services) Yes
lobehub/packages/database/ (models) Yes
lobehub/packages/types/ Yes
lobehub/packages/prompts/ Yes
lobehub/apps/cli/ (CLI code) No
src/ (cloud overrides) Yes

When Server Restart is NOT Needed

CLI runs from source via bun src/index.ts, so any changes to lobehub/apps/cli/src/ take effect immediately on next command invocation.

Troubleshooting

Issue Solution
No authentication found Run login --server http://localhost:3011
UNAUTHORIZED on API calls Token expired; re-run login
ECONNREFUSED Dev server not running; start with pnpm run dev:next
CLI shows old data/behavior Server needs restart to pick up code changes
EADDRINUSE on port 3011 Server already running; kill with lsof -ti:3011 \| xargs kill
Login opens wrong server Must use --server http://localhost:3011 flag (env var doesn't work)

Credential Isolation

Mode Credential Dir Server
Dev lobehub/apps/cli/.lobehub-dev/ localhost:3011
Production ~/.lobehub/ app.lobehub.com

The two environments are completely isolated. Dev mode credentials are gitignored.