OpenParable
Skip to content
← Back to skills

Sse

Development
sse

Sse is an Agent Skill for development published in the a5c-ai/babysitter repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Server-Sent Events implementation, streaming patterns, and real-time updates.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/a5c-ai/babysitter/blob/HEAD/library/specializations/web-development/skills/sse/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/sse, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

SSE Skill

Expert assistance for implementing Server-Sent Events for real-time streaming.

Capabilities

  • Implement SSE endpoints
  • Handle streaming responses
  • Manage client connections
  • Build event-driven updates
  • Implement reconnection

Usage

Invoke this skill when you need to:

  • Stream updates to clients
  • Implement live feeds
  • Build notification systems
  • One-way real-time communication

Implementation

// Server
app.get('/events', (req, res) => {
  res.setHeader('Content-Type', 'text/event-stream');
  res.setHeader('Cache-Control', 'no-cache');
  res.setHeader('Connection', 'keep-alive');

  const sendEvent = (event: string, data: object) => {
    res.write(`event: ${event}\n`);
    res.write(`data: ${JSON.stringify(data)}\n\n`);
  };

  // Send initial data
  sendEvent('connected', { timestamp: Date.now() });

  // Subscribe to updates
  const unsubscribe = eventEmitter.on('update', (data) => {
    sendEvent('update', data);
  });

  req.on('close', () => {
    unsubscribe();
  });
});

// Client
const eventSource = new EventSource('/events');

eventSource.addEventListener('update', (event) => {
  const data = JSON.parse(event.data);
  console.log('Update:', data);
});

Best Practices

  • Handle reconnection
  • Use event types for routing
  • Implement keep-alive
  • Clean up on disconnect

Target Processes

  • real-time-updates
  • live-feeds
  • notification-systems