.agents/skills/s2-best-practices/SKILL.md
# S2 Best Practices This skill provides guidance for using and configuring S2, a streaming data platform. ## Overview S2 is a managed streaming data platform that provides real-time data ingestion, processing, and querying capabilities. This skill covers: - S2 CLI usage - Access token management - Basin and stream configuration - Declarative spec files - Integration patterns ## Installation ### CLI Installation ```bash # Install the S2 CLI curl -sSfL https://install.s2.dev | sh # Or use
npx skillsauth add em-jones/staccato-toolkit .agents/skills/s2-best-practicesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides guidance for using and configuring S2, a streaming data platform.
S2 is a managed streaming data platform that provides real-time data ingestion, processing, and querying capabilities. This skill covers:
# Install the S2 CLI
curl -sSfL https://install.s2.dev | sh
# Or use Homebrew (macOS)
brew install s2dev/s2/s2
# Verify installation
s2 --version
Choose the appropriate SDK for your language:
npm install @s2dev/sdkpip install s2-sdkgo get github.com/s2dev/sdk-gocargo add s2-sdkConfigure the S2 CLI with your API endpoint and authentication:
# Set the API endpoint
s2 config set api.endpoint https://api.s2.dev
# Set default output format
s2 config set output.format json
# Enable/disable verbose logging
s2 config set log.level info
Configuration is stored in ~/.config/s2/config.yaml.
Access tokens provide authentication to S2 APIs:
# Issue a new access token
s2 access-tokens issue --name "my-token" --expires-in 720h
# List existing access tokens
s2 access-tokens list
# Revoke an access token
s2 access-tokens revoke <token-id>
Tokens should be stored securely and rotated regularly.
Basins are containers for streams that provide isolation and resource boundaries:
# Create a new basin
s2 basins create --name "my-basin" --description "Development basin"
# List basins
s2 basins list
# Get basin configuration
s2 basins get-config my-basin
# Delete a basin
s2 basins delete my-basin
Streams are unbounded sequences of records within a basin:
# Create a new stream
s2 streams create --basin my-basin --name "events" --schema '{"type":"record","name":"Event","fields":[{"name":"id","type":"string"},{"name":"timestamp","type":"long"},{"name":"data","type":"string"}]}'
# List streams in a basin
s2 streams list --basin my-basin
# Get stream configuration
s2 streams get-config my-basin events
# Delete a stream
s2 streams delete my-basin events
Records are the fundamental units of data in S2 streams:
# Append records to a stream
echo '{"id": "1", "timestamp": 1234567890, "data": "test"}' | s2 append my-basin events
# Read records from a stream
s2 read my-basin events --limit 10
# Check the tail position of a stream
s2 check-tail my-basin events
Define basins and streams using declarative spec files:
# s2-spec.yaml
basins:
- name: production
description: Production workloads
streams:
- name: user-events
schema:
type: record
name: UserEvent
fields:
- name: userId
type: string
- name: action
type: string
- name: timestamp
type: long
- name: system-metrics
schema:
type: record
name: SystemMetric
fields:
- name: service
type: string
- name: metric
type: string
- name: value
type: double
- name: timestamp
type: long
- name: development
description: Development and testing
streams:
- name: debug-logs
schema:
type: record
name: DebugLog
fields:
- name: level
type: string
- name: message
type: string
- name: timestamp
type: long
Apply the spec:
s2 apply -f s2-spec.yaml
Export metrics and traces to S2 using the OpenTelemetry integration:
# Configure OTLP exporter to point to S2
export OTEL_EXPORTER_OTLP_ENDPOINT="https://otlp.s2.dev:4317"
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <access-token>"
# Run your application with OpenTelemetry instrumentation
Manage S2 resources with Terraform:
# Configure the S2 provider
provider "s2" {
api_endpoint = "https://api.s2.dev"
access_token = var.s2_access_token
}
# Create a basin
resource "s2_basin" "example" {
name = "example-basin"
description = "Example basin for Terraform"
}
# Create a stream
resource "s2_stream" "example" {
basin_id = s2_basin.example.id
name = "example-stream"
schema = <<SCHEMA
{
"type": "record",
"name": "ExampleRecord",
"fields": [
{"name": "id", "type": "string"},
{"name": "data", "type": "string"}
]
}
SCHEMA
}
Stream AI-generated content with S2:
import { S2Stream } from "@s2dev/vercel-ai-sdk";
// Create a stream for AI responses
const stream = new S2Stream({
basin: "ai-basin",
stream: "llm-responses",
accessToken: process.env.S2_ACCESS_TOKEN,
});
// Write AI-generated tokens to the stream
for await (const token of llm.stream()) {
await stream.write({ token, timestamp: Date.now() });
}
# Enable verbose logging for troubleshooting
s2 --verbose streams list --basin my-basin
# Check API connectivity
s2 ping
# View current configuration
s2 config list
# Get detailed error information
s2 streams get-config my-basin problematic-stream --output yaml
tools
<!--VITE PLUS START--> # Using Vite+, the Unified Toolchain for the Web This project is using Vite+, a unified toolchain built on top of Vite, Rolldown, Vitest, tsdown, Oxlint, Oxfmt, and Vite Task. Vite+ wraps runtime management, package management, and frontend tooling in a single global CLI called `vp`. Vite+ is distinct from Vite, but it invokes Vite through `vp dev` and `vp build`. ## Vite+ Workflow `vp` is a global binary that handles the full development lifecycle. Run `vp help` to pr
development
Guide for building performant data tables. Uses tanstack-table for table logic (sorting, filtering, pagination) and tanstack-virtual for rendering large datasets efficiently.
development
Expert guidance for building observable, expressive, and fault-tolerant TypeScript applications using the effect-ts/effect ecosystem. Covers Effect<A, E, R> type, error management, dependency injection via Layers, observability (logging, metrics, tracing), concurrency with Fibers, retry/scheduling, Schema validation, Streams, and Sinks.
tools
Complete E2E (end-to-end) and integration testing skill for TypeScript/NestJS projects using Jest, real infrastructure via Docker, and GWT pattern. ALWAYS use this skill when user needs to: **SETUP** - Initialize or configure E2E testing infrastructure: - Set up E2E testing for a new project - Configure docker-compose for testing (Kafka, PostgreSQL, MongoDB, Redis) - Create jest-e2e.config.ts or E2E Jest configuration - Set up test helpers for database, Kafka, or Redis - Configure .env.e2e environment variables - Create test/e2e directory structure **WRITE** - Create or add E2E/integration tests: - Write, create, add, or generate e2e tests or integration tests - Test API endpoints, workflows, or complete features end-to-end - Test with real databases, message brokers, or external services - Test Kafka consumers/producers, event-driven workflows - Working on any file ending in .e2e-spec.ts or in test/e2e/ directory - Use GWT (Given-When-Then) pattern for tests **REVIEW** - Audit or evaluate E2E tests: - Review existing E2E tests for quality - Check test isolation and cleanup patterns - Audit GWT pattern compliance - Evaluate assertion quality and specificity - Check for anti-patterns (multiple WHEN actions, conditional assertions) **RUN** - Execute or analyze E2E test results: - Run E2E tests - Start/stop Docker infrastructure for testing - Analyze E2E test results - Verify Docker services are healthy - Interpret test output and failures **DEBUG** - Fix failing or flaky E2E tests: - Fix failing E2E tests - Debug flaky tests or test isolation issues - Troubleshoot connection errors (database, Kafka, Redis) - Fix timeout issues or async operation failures - Diagnose race conditions or state leakage - Debug Kafka message consumption issues **OPTIMIZE** - Improve E2E test performance: - Speed up slow E2E tests - Optimize Docker infrastructure startup - Replace fixed waits with smart polling - Reduce beforeEach cleanup time - Improve test parallelization where safe Keywords: e2e, end-to-end, integration test, e2e-spec.ts, test/e2e, Jest, supertest, NestJS, Kafka, Redpanda, PostgreSQL, MongoDB, Redis, docker-compose, GWT pattern, Given-When-Then, real infrastructure, test isolation, flaky test, MSW, nock, waitForMessages, fix e2e, debug e2e, run e2e, review e2e, optimize e2e, setup e2e