微算力 · API 导航与自营网关
API 接入 EN
未登录登录
⚡

官方Raycast扩展开发完全指南

raycast · v1.0.0
开发 安全 S 级 作者 xaif 公开目录收录
2.5k 下载 3 安装 6.4k 收藏 19 浏览

简介

基于React与TypeScript构建Raycast原生扩展的官方API开发技能,覆盖UI组件、数据存储、AI与浏览器集成等完整能力

原始描述

Build and maintain Raycast extensions using the Raycast API. Triggers on @raycast/api, List, Grid, Detail, Form, AI.ask, LocalStorage, Cache, showToast, and BrowserExtension. Use this repo's references/api/*.md files as the primary source of truth for component specs and API usage.

通过你的 Agent 添加

安装目录:raycast/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/raycast/
Codex CLI~/.codex/skills/raycast/
DeepSeek Harness~/.agents/skills/raycast/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

技能正文


name: raycast description: "Build Raycast extensions with React and TypeScript, create Script Commands, and troubleshoot URL schemes and extension execution on macOS." category: macos risk: safe source: self source_type: self date_added: "2026-08-26" tags: ["raycast", "macos-launcher", "raycast-api", "react-typescript", "script-commands", "accessibility-window", "claude"] tools: ["claude", "cursor", "gemini", "codex"]

Raycast macOS Extensible Productivity Launcher AI Skill Guide (Claude)

Overview & Engine Architecture

Raycast is a high-speed, extensible macOS launcher engineered in native Swift with a React/TypeScript Extension Runtime (@raycast/api) running in a secure, embedded Node.js process. Raycast features standalone Script Commands (authored in Bash, Python, Swift, Ruby, or Node.js with special metadata comment headers), Quicklinks, dynamic Snippets with placeholders, AI Chat / Prompt integrations, and an Accessibility-driven Window Management engine. Claude operates as a Principal macOS Tool Architect and Raycast Extension Developer, specializing in React-based Raycast UI extension development, Script Command metadata authoring, TCC Accessibility permission diagnostics, and deep raycast:// URL scheme integration.

Raycast Multi-Tier Architecture & Extension Runtime Stack

┌─────────────────────────────────────────────────────────────┐
│                 Raycast Engine Architecture                 │
│                                                             │
│  Presentation & Native Swift Core                           │
│  ├── Low-Latency Swift HUD Window (Floating Global Launcher)│
│  ├── Spotlight Replacement & Global Hotkey Engine (⌘+Space) │
│  └── Accessibility Window Management (`AXUIElement` Engine) │
│                                                             │
│  Extension & React Runtime (`@raycast/api`)                 │
│  ├── Embedded Node.js Worker & React Reconciler             │
│  ├── Component Library (`List`, `Form`, `Detail`, `Grid`)   │
│  └── Action Panel (`ActionPanel`, `Action.CopyToClipboard`) │
│                                                             │
│  Script Commands & IPC Protocol                             │
│  ├── Script Command Runner (Metadata Header Parser)         │
│  └── Deep URL Scheme Engine (`raycast://extensions/...`)    │
└─────────────────────────────────────────────────────────────┘

Operational Capabilities & Agent Directives

  1. React / TypeScript Extension Authoring: Develop modular Raycast extensions using @raycast/api and @raycast/utils implementing List, Detail, Form, and ActionPanel views with clean state management.
  2. Metadata Script Command Authoring: Write standalone script commands in Bash, Python, or Swift with valid @raycast.schemaVersion, @raycast.title, @raycast.mode, and @raycast.icon headers.
  3. Accessibility Window Snapping Triage: Remediate window management failures by verifying Raycast's AXUIElement Accessibility permissions in macOS System Settings.
  4. Deep Linking & Quicklinks: Construct raycast:// URL schemes to trigger specific commands, execute extension deep links, and load custom AI prompts.

Production TypeScript Code: Custom Raycast Extension Command (@raycast/api)

Save this file as src/search-repositories.tsx inside a Raycast Extension project (npm install @raycast/api @raycast/utils):

// ==============================================================================
// Raycast Extension Command (React / TypeScript): GitHub Repo Switcher
// Fetches, filters, and opens local git repositories in VS Code or Terminal.
// ==============================================================================
import { Action, ActionPanel, Icon, List, showToast, Toast } from "@raycast/api";
import { useExec } from "@raycast/utils";
import { useState } from "react";

interface RepoItem {
  name: string;
  path: string;
}

export default function Command() {
  const [searchText, setSearchText] = useState("");

  // Scan user Projects directory using fast find command
  const { isLoading, data, error } = useExec(
    "find",
    ["/Users/" + process.env.USER + "/Projects", "-maxdepth", "2", "-name", ".git"],
    {
      onError: (err) => {
        showToast({
          style: Toast.Style.Failure,
          title: "Failed to scan projects",
          message: err.message,
        });
      },
    }
  );

  const repos: RepoItem[] = (data || "")
    .split("\n")
    .filter((line) => line.length > 0)
    .map((gitDir) => {
      const repoPath = gitDir.replace(/\/\.git$/, "");
      const repoName = repoPath.split("/").pop() || "Unnamed";
      return { name: repoName, path: repoPath };
    });

  const filteredRepos = repos.filter((r) =>
    r.name.toLowerCase().includes(searchText.toLowerCase())
  );

  return (
    <List
      isLoading={isLoading}
      onSearchTextChange={setSearchText}
      searchBarPlaceholder="Filter local git repositories..."
    >
      {filteredRepos.map((repo) => (
        <List.Item
          key={repo.path}
          icon={Icon.Folder}
          title={repo.name}
          subtitle={repo.path}
          actions={
            <ActionPanel>
              <Action.Open
                title="Open in VS Code"
                target={repo.path}
                application="Visual Studio Code"
              />
              <Action.Open
                title="Open in Terminal"
                target={repo.path}
                application="Terminal"
              />
              <Action.CopyToClipboard title="Copy Path" content={repo.path} />
            </ActionPanel>
          }
        />
      ))}
    </List>
  );
}

Technical Troubleshooting Matrix

Issue & Failure Signature Root Cause Analysis Diagnostic & Resolution Pathway
Window Management Commands (Snap/Resize) Fail Raycast lacks macOS Accessibility permissions to manipulate window bounds via AXUIElement. 1. Open System Settings $\rightarrow$ Privacy & Security $\rightarrow$ Accessibility.2. Toggle Raycast OFF and ON.3. Restart Raycast.
Script Command Does Not Appear in Launcher Script file missing executable bit (chmod +x) or contains malformed @raycast.schemaVersion header. 1. In terminal, run: chmod +x ~/.raycast-scripts/my_script.sh.2. Verify header format: // @raycast.schemaVersion 1 and // @raycast.title My Script.3. In Raycast Preferences $\rightarrow$ Extensions $\rightarrow$ Reload.
npm run dev Fails with Node.js Version Error Raycast API requires Node.js version 18.0.0 or higher. Update Node.js via Homebrew: brew install node or nvm use 20.
Command + Space Opens Apple Spotlight Instead macOS default Spotlight hotkey collision. In System Settings $\rightarrow$ Keyboard $\rightarrow$ Keyboard Shortcuts $\rightarrow$ Spotlight, uncheck Show Spotlight search, then assign ⌘ + Space to Raycast.

Command Line Syntax & Raycast Script Command Header Template

#!/usr/bin/env bash
# ==============================================================================
# Raycast Script Command Template (Save as executable script)
#
# @raycast.schemaVersion 1
# @raycast.title System Memory Free
# @raycast.mode compact
# @raycast.icon 🚀
# @raycast.packageName Developer Utilities
# ==============================================================================
echo "Free Memory: $(vm_stat | grep 'Pages free' | awk '{print $3 * 4096 / 1024 / 1024}') MB"

Essential File Locations

  • Raycast Application Support: ~/Library/Application Support/com.raycast.macos
  • Custom Script Commands: ~/Library/Application Support/com.raycast.macos/script-commands
  • Raycast Preferences: ~/Library/Preferences/com.raycast.macos.plist

Agent Operational Directive

MANDATORY: When authoring Raycast Script Commands, always specify @raycast.schemaVersion 1, assign an appropriate @raycast.mode (compact, fullOutput, or silent), and ensure executable file permissions (chmod +x).

正文来自原始仓库, 版权归作者所有,许可:Apache-2.0。 权利人认为有不妥,可申请下架。

原始仓库

作者的项目地址:https://github.com/alivirgo/Major-AI-Skills

标签

raycastmacosreacttypescriptcliproductivityapi-referenceextension-development

同类 Skill