mcpField
C
cli-skills

cli-skills

github.com/llama-farm開発83653 回インストール21 週間前に更新
リポジトリ

cli-skills について

cli-skills は、Cobra、Bubbletea、Lipgloss を使う LlamaFarm CLI 開発者向けのフレームワーク別ガイドです。共有 Go の実践に、コマンドラインと TUI のチェックリストを加えています。

主な機能

  1. 01Cobra コマンドとフラグのパターン
  2. 02Bubbletea のモデルと更新の指針
  3. 03Lipgloss のスタイル設定
  4. 04CLI パフォーマンスのチェックリスト
  5. 05サービスオーケストレーションのパターン

活用シーン

  1. 01Cobra コマンドと引数検証の実装
  2. 02Bubbletea によるターミナル UI の構築
  3. 03CLI 出力とサービス処理のレビュー

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/llama-farm/llamafarm --skill cli-skills

インストール後、Claude Code で/cli-skillsを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

bubbletea.md
cobra.md
performance.md

詳細

LlamaFarm 向け CLI スキル

LlamaFarm CLI に特化したパターンです。このガイドラインは、Cobra、Bubbletea、Lipgloss のベストプラクティスを加えて、共有 Go スキルを拡張します。

技術スタック

  • Go 1.24+
  • Cobra(CLI フレームワーク)
  • Bubbletea(TUI フレームワーク)
  • Lipgloss(ターミナルのスタイル設定)
  • Bubbles(TUI コンポーネント)

ディレクトリ構成

cli/
  cmd/             # Cobra command implementations
    config/        # Configuration types and loading
    orchestrator/  # Service management and process control
    utils/         # Shared utilities (HTTP, output, logging)
    version/       # Version and upgrade handling
  internal/        # Internal packages (not exported)
    tui/           # Reusable TUI components
    buildinfo/     # Build-time information

クイックリファレンス

Cobra コマンド
  • エラー処理には Run より RunE を使用します
  • init() 関数でフラグを登録します
  • 共通オプションには永続フラグを使用します
  • Args フィールドで引数を検証します
Bubbletea TUI
  • Init()、Update()、View() インターフェースを実装します
  • 状態の変更にはメッセージ型を使用します
  • 非同期処理には tea.Cmd を返します
  • Update() 内では状態を不変に保ちます
Lipgloss のスタイル設定
  • スタイルはパッケージレベルの定数として定義します
  • スタイル設定には lipgloss.NewStyle() を使用します
  • ターミナルの幅に動的に対応します
  • スタイル変数を使ってカラーテーマをサポートします

共有 Go スキル

このスキルは Go の基本スキルを拡張します。以下を参照してください。

リンク説明
go-skills/SKILL.md概要とクイックリファレンス
go-skills/patterns.md慣用的な Go のパターン
go-skills/concurrency.mdゴルーチン、チャネル、同期
go-skills/error-handling.mdエラーのラップ、センチネル
go-skills/testing.mdテーブル駆動テスト、モック
go-skills/security.md入力検証、安全なコーディング

CLI 固有のチェックリスト

ファイル説明
cobra.mdCobra のコマンドパターン、フラグ、検証
bubbletea.mdBubbletea の Model/Update/View パターン
performance.mdCLI 固有の最適化

このコードベースの主要なパターン

コマンド登録パターン
var myCmd = &cobra.Command{
    Use:   "mycommand [args]",
    Short: "Brief description",
    Long:  `Extended description with examples.`,
    Args:  cobra.MaximumNArgs(1),
    RunE: func(cmd *cobra.Command, args []string) error {
        // Implementation with error returns
        return nil
    },
}

func init() {
    rootCmd.AddCommand(myCmd)
    myCmd.Flags().StringVar(&flagVar, "flag", "default", "Flag description")
}
TUI モデルパターン
type myModel struct {
    viewport viewport.Model
    textarea textarea.Model
    width    int
    height   int
    err      error
}

func (m myModel) Init() tea.Cmd {
    return tea.Batch(m.textarea.Focus(), doAsyncWork())
}

func (m myModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
    var cmds []tea.Cmd
    switch msg := msg.(type) {
    case tea.WindowSizeMsg:
        m.width = msg.Width
        m.height = msg.Height
    case tea.KeyMsg:
        switch msg.String() {
        case "ctrl+c":
            return m, tea.Quit
        }
    }
    return m, tea.Batch(cmds...)
}

func (m myModel) View() string {
    return lipgloss.JoinVertical(lipgloss.Left,
        m.viewport.View(),
        m.textarea.View(),
    )
}
出力 API パターン
// Use the output API for consistent messaging
utils.OutputInfo("Starting service %s...", serviceName)
utils.OutputSuccess("Service started successfully")
utils.OutputError("Failed to start service: %v", err)
utils.OutputProgress("Downloading model...")
utils.OutputWarning("Service already running")
サービスオーケストレーションパターン
// Ensure services are running before operations
factory := GetServiceConfigFactory()
config := factory.ServerOnly(serverURL)
orchestrator.EnsureServicesOrExitWithConfig(config, "server")

// Or with multiple services
config := factory.RAGCommand(serverURL)
orchestrator.EnsureServicesOrExitWithConfig(config, "server", "rag", "universal-runtime")

ガイドライン

  1. ユーザー体験を最優先:CLI は応答性が高く、明確なフィードバックを提供する必要があります
  2. 適切な縮退動作:サービスの不足、ネットワークエラー、タイムアウトに適切に対処します
  3. 一貫した出力:ユーザー向けメッセージにはすべて出力 API を使用します
  4. クロスプラットフォーム対応:macOS、Linux、Windows でテストします
  5. ターミナル互換性:さまざまなターミナルエミュレーターとサイズでテストします

コメント