home / skills / numman-ali / n-skills / zai-cli

This skill helps you efficiently analyze images, search the web, read pages, and explore GitHub through the ZAI CLI.

npx playbooks add skill numman-ali/n-skills --skill zai-cli

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
2.1 KB
---
name: zai-cli
description: |
  Z.AI CLI providing:
  - Vision: image/video analysis, OCR, UI-to-code, error diagnosis (GLM-4.6V)
  - Search: real-time web search with domain/recency filtering
  - Reader: web page to markdown extraction
  - Repo: GitHub code search and reading via ZRead
  - Tools: MCP tool discovery and raw calls
  - Code: TypeScript tool chaining
  Use for visual content analysis, web search, page reading, or GitHub exploration. Requires Z_AI_API_KEY.
---

# ZAI CLI

Access Z.AI capabilities via `npx zai-cli`. The CLI is self-documenting - use `--help` at any level.

## Setup

```bash
export Z_AI_API_KEY="your-api-key"
```

Get a key at: https://z.ai/manage-apikey/apikey-list

## Commands

| Command | Purpose | Help |
|---------|---------|------|
| vision | Analyze images, screenshots, videos | `--help` for 8 subcommands |
| search | Real-time web search | `--help` for filtering options |
| read | Fetch web pages as markdown | `--help` for format options |
| repo | GitHub code search and reading | `--help` for tree/search/read |
| tools | List available MCP tools | |
| tool | Show tool schema | |
| call | Raw MCP tool invocation | |
| code | TypeScript tool chaining | |
| doctor | Check setup and connectivity | |

## Quick Start

```bash
# Analyze an image
npx zai-cli vision analyze ./screenshot.png "What errors do you see?"

# Search the web
npx zai-cli search "React 19 new features" --count 5

# Read a web page
npx zai-cli read https://docs.example.com/api
npx zai-cli read https://docs.example.com/api --with-images-summary --no-gfm

# Explore a GitHub repo
npx zai-cli repo search facebook/react "server components"
npx zai-cli repo search openai/codex "config" --language en
npx zai-cli repo tree openai/codex --path codex-rs --depth 2

# Check setup
npx zai-cli doctor
```

## Output

Default: **data-only** (raw output for token efficiency).
Use `--output-format json` for `{ success, data, timestamp }` wrapping.

## Advanced

For raw MCP tool calls (`tools`, `tool`, `call`), Code Mode, and performance tuning (cache/retries),
see `references/advanced.md`.

Overview

This skill is a CLI wrapper for Z.AI capabilities that exposes vision, search, web reading, GitHub repo exploration, tool discovery, and TypeScript tool chaining. It is designed for developers and analysts who want fast, scriptable access to image/video analysis, real-time web search, page-to-markdown extraction, and codebase inspection. The CLI requires a Z_AI_API_KEY to authenticate and runs via npx for quick setup.

How this skill works

The CLI issues requests to Z.AI services using your API key and returns machine-friendly, data-only responses by default for token efficiency. Commands map to service areas: vision analyzes images and video (OCR, UI-to-code, error diagnosis), search performs real-time web queries with domain and recency filters, read extracts web pages into markdown, and repo performs GitHub search and tree reads via ZRead. Advanced commands expose MCP tool schemas and raw tool invocation, and a TypeScript 'code' mode enables chaining tools programmatically.

When to use it

  • Debug UI screenshots or videos to locate errors, text, or actionable UI elements.
  • Perform live web research with domain or recency filters for up-to-date results.
  • Convert documentation or articles into markdown for editing or indexing.
  • Search and explore GitHub repositories for code snippets, file trees, and context.
  • Automate tool workflows or prototype integrations using raw MCP tool calls or TypeScript chaining.

Best practices

  • Set Z_AI_API_KEY as an environment variable before running commands (export Z_AI_API_KEY="...").
  • Prefer data-only output for script pipelines; use --output-format json when you need metadata wrapping.
  • Use --help at any command level to discover subcommands and filtering options before running complex queries.
  • For vision tasks, provide focused prompts and relevant crop/frames to improve accuracy on screenshots or videos.
  • Combine repo tree and search to locate files, then use read to extract documentation into markdown for review.

Example use cases

  • Analyze a failing app screenshot: npx zai-cli vision analyze ./screenshot.png "What errors do you see?"
  • Gather recent web findings on a library: npx zai-cli search "React 19 new features" --count 5 --recency 30d
  • Convert API docs to markdown including image summaries for a knowledge base: npx zai-cli read https://docs.example.com/api --with-images-summary
  • Investigate a GitHub project structure and read files: npx zai-cli repo tree openai/codex --path codex-rs --depth 2
  • List available MCP tools and call one directly for automation prototyping: npx zai-cli tools && npx zai-cli call <tool> --input '{...}'

FAQ

How do I authenticate the CLI?

Set your Z_AI_API_KEY environment variable (export Z_AI_API_KEY="your-api-key"). Get keys from the Z.AI dashboard.

What output formats are available?

Default is data-only raw output. Use --output-format json to wrap responses with { success, data, timestamp }.