add-ws-action

Add a new outgoing WebSocket action with typed payload and API exposure

181 stars

Best use case

add-ws-action is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Add a new outgoing WebSocket action with typed payload and API exposure

Teams using add-ws-action should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/add-ws-action/SKILL.md --create-dirs "https://raw.githubusercontent.com/majiayu000/claude-skill-registry/main/skills/data/add-ws-action/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/add-ws-action/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How add-ws-action Compares

Feature / Agentadd-ws-actionStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Add a new outgoing WebSocket action with typed payload and API exposure

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Add WebSocket Action Skill

## Usage
```
/add-ws-action <actionName>
```

---

## Step 1: Ask Questions

### 1. Action Purpose
```
What does this action do?
Brief description:
```

### 2. Parameters
```
What parameters does the action need?

List each with type:
- param1: string
- param2: number
- etc.
```

### 3. Public API
```
Expose in window.Gemini.WebSocket?

A) Yes - Users can call it
B) No - Internal only (used by features)
```

### 4. Middleware
```
Does this action need middleware?

A) No - Just send
B) Yes - Intercept/modify/block
```

---

## Step 2: Add Message Type

### In `src/websocket/protocol.ts`

```typescript
// 1. Add to enum
export enum ClientToServerMessageType {
    // ... existing
    <ACTION_NAME> = '<actionName>',
}

// 2. Define payload type
export interface <ActionName>Payload {
    param1: string;
    param2: number;
}

// 3. Add to message map (if exists)
export interface ClientToServerMessageMap {
    // ... existing
    [ClientToServerMessageType.<ACTION_NAME>]: <ActionName>Payload;
}
```

---

## Step 3: Add Action to API

### In `src/websocket/api.ts`

```typescript
import { ClientToServerMessageType } from './protocol';
import { send } from './connection';
import type { <ActionName>Payload } from './protocol';

/**
 * <Description of what this action does>
 * @param param1 - Description
 * @param param2 - Description
 */
export function <actionName>(param1: string, param2: number): void {
    send({
        type: ClientToServerMessageType.<ACTION_NAME>,
        data: { param1, param2 } satisfies <ActionName>Payload,
    });
}
```

**Keep API simple** - Users pass parameters, not raw payloads.

---

## Step 4: Expose in Public API (if applicable)

### In `src/api/index.ts`

```typescript
import { <actionName> } from '../websocket/api';

WebSocket: {
    // ... existing
    <actionName>,
}
```

Accessible via `window.Gemini.WebSocket.<actionName>(...)`.

---

## Step 5: Optional - Add Middleware

### Create `src/websocket/middlewares/<actionName>.ts`

```typescript
import { registerMiddleware } from './registry';
import { ClientToServerMessageType } from '../protocol';
import type { ClientToServerMessage } from '../protocol';

let unregister: (() => void) | null = null;

function processMessage(message: ClientToServerMessage): ClientToServerMessage | null {
    if (message.type !== ClientToServerMessageType.<ACTION_NAME>) {
        return message;  // Pass through
    }

    console.log('[<ActionName>] Intercepted:', message.data);

    // Modify
    // return { ...message, data: { ...message.data, modified: true } };

    // Block
    // return null;

    // Pass through
    return message;
}

export function register<ActionName>Middleware(): void {
    if (unregister) return;
    unregister = registerMiddleware(processMessage);
}

export function unregister<ActionName>Middleware(): void {
    unregister?.();
    unregister = null;
}
```

---

## Step 6: Validate

### Protocol
- [ ] Message type added to `ClientToServerMessageType` enum
- [ ] Payload interface defined
- [ ] No hardcoded type strings

### API
- [ ] Action function in `src/websocket/api.ts`
- [ ] Typed parameters (no `unknown` or `any`)
- [ ] Uses `send()` from `connection.ts`
- [ ] JSDoc documentation

### Public API (if applicable)
- [ ] Exposed in `src/api/index.ts`
- [ ] Callable via `window.Gemini.WebSocket.<actionName>()`

### Middleware (if applicable)
- [ ] Returns `message` or `null`, never throws
- [ ] Has register/unregister functions
- [ ] Unregisters on cleanup

---

## References

- Rules: `.claude/rules/websocket/websocket.md`
- Existing actions: `src/websocket/api.ts`
- Protocol: `src/websocket/protocol.ts`
- Middlewares: `src/websocket/middlewares/`

Related Skills

adr-decision-extraction

181
from majiayu000/claude-skill-registry

Extract architectural decisions from conversations. Identifies problem-solution pairs, trade-off discussions, and explicit choices. Use when analyzing session transcripts for ADR generation.

add-reaction

181
from majiayu000/claude-skill-registry

Slack メッセージにリアクションを追加する。「リアクション追加」「リアクションつけて」「👍つけて」「絵文字で反応」「リアクションで返信」「いいねして」「リアクション送って」などで起動。User Token があればユーザーとしてリアクション、なければ Bot としてリアクション。

github-actions

181
from majiayu000/claude-skill-registry

Create and configure GitHub Actions. Use when building custom actions, setting up runners, implementing security practices, or publishing to the marketplace.

actions-pattern

181
from majiayu000/claude-skill-registry

Garante que novas Actions sigam o padrão de classes actions reutilizáveis do Easy Budget.

actions-debugger

181
from majiayu000/claude-skill-registry

GitHub Actions のワークフロー実行エラーを調査し、原因を特定して解決策を提案する。「Actions エラー」「ワークフロー失敗」「CI が落ちた」「ビルド失敗」「テスト失敗」「Actions を調べて」「CI のエラーを見て」などで起動。失敗したジョブのログを分析し、具体的な修正方法を提示。

actions-cicd-practices

181
from majiayu000/claude-skill-registry

GitHub Actions and CI/CD best practices for automated testing, building, and deployment.

actionbook

181
from majiayu000/claude-skill-registry

This skill should be used when the user needs to automate multi-step website tasks. Activates for browser automation, web scraping, UI testing, or building AI agents. Provides complete action manuals with step-by-step instructions and verified selectors.

actionable-review-format-standards

181
from majiayu000/claude-skill-registry

Standardized output format for code reviews with severity labels, file:line references, and fix code snippets. Use when generating review reports that need consistent, actionable feedback structure.

actionable-alerting-runbook-design

181
from majiayu000/claude-skill-registry

Designing effective alerts and runbooks for incident response. PROACTIVELY activate for: (1) Creating alerting rules, (2) Writing runbooks, (3) Reducing alert fatigue, (4) On-call escalation setup, (5) Incident response procedures. Triggers: "alerting", "runbook", "on-call", "pagerduty", "incident", "alert fatigue", "escalation", "playbook"

action

181
from majiayu000/claude-skill-registry

Execute a small batch of conditional actions only after verifying they are safe and unused.

action-queue

181
from majiayu000/claude-skill-registry

Sims-inspired task scheduling — queue actions, execute in order

action-policy-coder

181
from majiayu000/claude-skill-registry

Use proactively for authorization with ActionPolicy. Creates policies, scopes, and integrates with GraphQL/ActionCable. Preferred over Pundit for composable, cacheable authorization.