add-ws-action

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

16 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/diegosouzapw/awesome-omni-skill/main/skills/backend/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

action_logger

16
from diegosouzapw/awesome-omni-skill

Keep an audit trail of changes, commands, and verification.

action-mailer-coder

16
from diegosouzapw/awesome-omni-skill

Use when creating or refactoring Action Mailer emails. Applies Rails 7.1+ conventions, parameterized mailers, preview workflows, background delivery, and email design best practices.

python-github-actions

16
from diegosouzapw/awesome-omni-skill

Complete Python GitHub Actions system. PROACTIVELY activate for: (1) uv-based CI workflows (10-100x faster), (2) Matrix testing across Python versions, (3) Dependency caching with setup-uv, (4) Parallel test execution, (5) Reusable workflows, (6) Publishing to PyPI with trusted publishing, (7) Code coverage with codecov, (8) Security scanning. Provides: Workflow templates, caching config, matrix strategies, composite actions. Ensures fast, reliable CI/CD pipelines.

form-and-actions-in-sveltekit

16
from diegosouzapw/awesome-omni-skill

Describes Form and Actions implementations.

asyncredux-async-actions

16
from diegosouzapw/awesome-omni-skill

Creates AsyncRedux (Flutter) asynchronous actions for API calls, database operations, and other async work.

adr-decision-extraction

16
from diegosouzapw/awesome-omni-skill

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

bgo

10
from diegosouzapw/awesome-omni-skill

Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.

Coding & Development

mcp-create-declarative-agent

16
from diegosouzapw/awesome-omni-skill

Skill converted from mcp-create-declarative-agent.prompt.md

MCP Architecture Expert

16
from diegosouzapw/awesome-omni-skill

Design and implement Model Context Protocol servers for standardized AI-to-data integration with resources, tools, prompts, and security best practices

mathem-shopping

16
from diegosouzapw/awesome-omni-skill

Automatiserar att logga in på Mathem.se, söka och lägga till varor från en lista eller recept, hantera ersättningar enligt policy och reservera leveranstid, men lämnar varukorgen redo för manuell checkout.

math-modeling

16
from diegosouzapw/awesome-omni-skill

本技能应在用户要求"数学建模"、"建模比赛"、"数模论文"、"数学建模竞赛"、"建模分析"、"建模求解"或提及数学建模相关任务时使用。适用于全国大学生数学建模竞赛(CUMCM)、美国大学生数学建模竞赛(MCM/ICM)等各类数学建模比赛。

matchms

16
from diegosouzapw/awesome-omni-skill

Mass spectrometry analysis. Process mzML/MGF/MSP, spectral similarity (cosine, modified cosine), metadata harmonization, compound ID, for metabolomics and MS data processing.