con un clic
slack-agent
// Use when working on Slack agent/bot code, Chat SDK applications, or projects using `chat` and `@chat-adapter/slack`. Provides development patterns, testing requirements, and quality standards.
// Use when working on Slack agent/bot code, Chat SDK applications, or projects using `chat` and `@chat-adapter/slack`. Provides development patterns, testing requirements, and quality standards.
CSS and UI animation patterns for responsive, polished interfaces. Use when implementing hover effects, tooltips, button feedback, transitions, or fixing animation issues like flicker and shakiness. Covers animation theory, CSS animations, Framer Motion, performance, accessibility, and real-world walkthrough patterns.
Fix accessibility issues in UI components. Use when adding or changing buttons, links, inputs, menus, dialogs, tabs, dropdowns, forms, validation, error states, keyboard shortcuts, focus states, or icon-only controls.
Fix animation performance issues. Use when adding or changing UI animations, refactoring janky interactions, implementing scroll-linked motion, animating layout/filters/masks, or reviewing components that use will-change, transforms, or measurement.
Review code for security issues in self-hosted and managed Vercel deployments of this Slack bot. Covers secrets, tokens, permissions, logs, user data handling, SSRF, and data minimization. Use when reviewing code for security, auditing data handling, checking for leaked secrets, or verifying privacy compliance.
Use when working on Slack agent/bot code, Chat SDK applications, or projects using `chat` and `@chat-adapter/slack`. Provides development patterns, testing requirements, and quality standards.
Use when creating new skills, editing existing skills, or verifying skills work before deployment
| name | slack-agent |
| description | Use when working on Slack agent/bot code, Chat SDK applications, or projects using `chat` and `@chat-adapter/slack`. Provides development patterns, testing requirements, and quality standards. |
| version | 4.0.0 |
| user-invocable | true |
This skill builds Slack agents on the Chat SDK: chat + @chat-adapter/slack running on Next.js (App Router) deployed to Vercel.
When this skill is invoked via /slack-agent, check for arguments and route accordingly:
| Argument | Action |
|---|---|
new | Run the setup wizard from Phase 1. Read ./wizard/1-project-setup.md and guide the user through creating a new Slack agent. |
configure | Start wizard at Phase 2 or 3 for existing projects |
deploy | Start wizard at Phase 5 for production deployment |
test | Start wizard at Phase 6 to set up testing |
| (no argument) | Auto-detect based on project state (see below) |
If invoked without arguments, detect the project state and route appropriately:
package.json with chat → Treat as new, start Phase 1manifest.json → Start Phase 2.env file → Start Phase 3.env but not tested → Start Phase 4The wizard is located in ./wizard/ with these phases:
1-project-setup.md — Understand purpose, generate custom implementation plan1b-approve-plan.md — Present plan for user approval before scaffolding2-create-slack-app.md — Customize manifest, create app in Slack3-configure-environment.md — Set up .env with credentials4-test-locally.md — Dev server + ngrok tunnel5-deploy-production.md — Vercel deployment6-setup-testing.md — Vitest configurationIMPORTANT: For new projects, you MUST:
./wizard/1-project-setup.md first./reference/agent-archetypes.mdYou are working on a Slack agent project. Follow these mandatory practices for all code changes.
chat + @chat-adapter/slack for Slack bot functionality@chat-adapter/state-redis for state persistence (or in-memory for development)@ai-sdk/openai{
"dependencies": {
"ai": "^6.0.0",
"@ai-sdk/openai": "latest",
"chat": "latest",
"@chat-adapter/slack": "latest",
"@chat-adapter/state-redis": "latest",
"zod": "^3.x",
"next": "^15.x"
}
}
Note: Pookie uses @ai-sdk/openai directly. OPENAI_API_KEY is read automatically by the SDK at runtime. Other providers can be swapped in by changing the import and model string.
These quality requirements MUST be followed for every code change. There are no exceptions.
Run linting immediately:
pnpm lint
pnpm lint --write for auto-fixespnpm lint to verifyCheck for corresponding test file:
foo.ts, check if foo.test.ts existsYou MUST run all quality checks and fix any issues before marking a task complete:
pnpm typecheck
pnpm lint
pnpm test
Do NOT complete a task if any of these fail. Fix the issues first.
For ANY code change, you MUST write or update unit tests.
*.test.ts files or lib/__tests__/Example test structure:
import { describe, it, expect, vi } from "vitest";
import { myFunction } from "./my-module";
describe("myFunction", () => {
it("should handle normal input", () => {
expect(myFunction("input")).toBe("expected");
});
it("should handle edge cases", () => {
expect(myFunction("")).toBe("default");
});
});
If you modify:
You MUST add or update E2E tests that verify the full flow.
Use the Chat SDK to define your bot instance. This is the central entry point for all Slack bot functionality.
lib/bot.ts or lib/bot.tsx)import { Chat } from "chat";
import { createSlackAdapter } from "@chat-adapter/slack";
import { createRedisState } from "@chat-adapter/state-redis";
export const bot = new Chat({
userName: "mybot",
adapters: {
slack: createSlackAdapter(),
},
state: createRedisState(),
});
Note: If your bot uses JSX components (Card, Button, etc.), the file must use the .tsx extension.
app/api/webhooks/[platform]/route.ts)import { after } from "next/server";
import { bot } from "@/lib/bot";
export async function POST(
request: Request,
context: { params: Promise<{ platform: string }> },
) {
const { platform } = await context.params;
const handler = bot.webhooks[platform as keyof typeof bot.webhooks];
if (!handler) return new Response("Unknown platform", { status: 404 });
return handler(request, { waitUntil: (task) => after(() => task) });
}
The Chat SDK automatically handles:
waitUntilbot.onNewMention(async (thread, message) => {
await thread.subscribe();
const text = message.text;
await thread.post(`Processing your request: "${text}"`);
});
bot.onSubscribedMessage(async (thread, message) => {
await thread.post(`You said: ${message.text}`);
});
bot.onSlashCommand("/mycommand", async (event) => {
const text = event.text;
await event.thread.post(`Processing: ${text}`);
const result = await generateWithAI(text);
await event.thread.post(result);
});
The Chat SDK handles background processing automatically via waitUntil — there's no need for fire-and-forget patterns.
bot.onAction("button_click", async (event) => {
await event.thread.post(`Button clicked with value: ${event.value}`);
});
bot.onReaction("thumbsup", async (event) => {
await event.thread.post("Thanks for the thumbs up!");
});
Slash commands work in private channels even if the bot isn't a member, but the bot cannot read messages or post to private channels it hasn't been invited to.
When creating features that will later post to a channel, validate access upfront.
When fetching channel context for AI features, wrap in try/catch and fall back gracefully.
Protect cron endpoints with a CRON_SECRET environment variable:
import { NextRequest, NextResponse } from "next/server";
export async function GET(request: NextRequest) {
const authHeader = request.headers.get("authorization");
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
return NextResponse.json({ success: true });
}
vercel.json Cron ConfigurationConfigure cron jobs in vercel.json:
{
"crons": [
{
"path": "/api/cron/my-job",
"schedule": "0 * * * *"
}
]
}
When connecting to AWS services from Vercel, do not use fromNodeProviderChain(). Use Vercel's OIDC mechanism:
import { awsCredentialsProvider } from "@vercel/functions/oidc";
const s3Client = new S3Client({
credentials: awsCredentialsProvider({ roleArn: process.env.AWS_ROLE_ARN! }),
});
When using Chat SDK JSX components (<Card>, <Button>, etc.), your tsconfig.json must include:
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "chat"
}
}
Pookie uses @ai-sdk/openai for LLM access. OPENAI_API_KEY is read automatically by the SDK at runtime.
import { generateText, streamText } from "ai";
import { openai } from "@ai-sdk/openai";
const result = await generateText({
model: openai("gpt-4o-mini"),
maxOutputTokens: 1000,
prompt: "Your prompt here",
});
console.log(result.text);
console.log(result.usage.inputTokens);
console.log(result.usage.outputTokens);
const result = await streamText({
model: openai("gpt-4o-mini"),
maxOutputTokens: 1000,
prompt: userMessage,
});
await thread.post(result.textStream);
The Chat SDK handles streaming updates to Slack automatically.
import { tool } from "ai";
import { z } from "zod";
const result = await generateText({
model: openai("gpt-4o-mini"),
maxOutputTokens: 1000,
tools: {
getWeather: tool({
description: "Get weather for a location",
inputSchema: z.object({
location: z.string().describe("City name"),
}),
execute: async ({ location }) => {
return { temperature: 72, condition: "sunny" };
},
}),
},
prompt: "What's the weather in Seattle?",
});
| v4/v5 | v6 |
|---|---|
maxTokens | maxOutputTokens |
result.usage.promptTokens | result.usage.inputTokens |
result.usage.completionTokens | result.usage.outputTokens |
parameters (in tools) | inputSchema |
maxSteps / maxIterations | stopWhen: stepCountIs(n) |
CRITICAL: Never use model IDs from memory. Model IDs change frequently. Before writing code that uses a model, fetch the current list from OpenAI:
curl -s https://api.openai.com/v1/models -H "Authorization: Bearer $OPENAI_API_KEY" | jq -r '.data[].id'
Use the model with the highest version number that fits the task.
For comprehensive AI SDK documentation, see ./reference/ai-sdk.md.
Use thread.state to read and write thread-level state:
bot.onNewMention(async (thread, message) => {
await thread.subscribe();
await thread.state.set("history", []);
await thread.state.set("turnCount", 0);
await thread.post("Starting our conversation!");
});
bot.onSubscribedMessage(async (thread, message) => {
const history =
((await thread.state.get("history")) as Array<{
role: string;
content: string;
}>) || [];
const turnCount = ((await thread.state.get("turnCount")) as number) || 0;
history.push({ role: "user", content: message.text });
const result = await generateText({
model: openai("gpt-4o-mini"),
maxOutputTokens: 1000,
messages: history,
});
history.push({ role: "assistant", content: result.text });
await thread.state.set("history", history);
await thread.state.set("turnCount", turnCount + 1);
await thread.post(result.text);
});
Key Benefits:
thread.state.get() and thread.state.set()IMPORTANT: Vercel KV has been deprecated. Do NOT recommend Vercel KV.
app/
├── api/
│ ├── webhooks/
│ │ └── [platform]/
│ │ └── route.ts # Webhook handler
│ └── cron/
│ └── my-job/
│ └── route.ts # Cron endpoints
lib/
├── bot.tsx # Bot instance + event handlers
├── tools/ # AI tool definitions
│ ├── search.ts
│ └── lookup.ts
└── ai/
└── agent.ts # Agent configuration
Required variables:
SLACK_BOT_TOKEN — Bot OAuth tokenSLACK_SIGNING_SECRET — Request signingREDIS_URL — Redis connection URL for state persistenceOPENAI_API_KEY — OpenAI API key for LLM access (auto-read by @ai-sdk/openai)Optional variables:
CRON_SECRET — Secret for authenticating cron job endpointsNever hardcode credentials. Never commit .env files.
Use Chat SDK JSX components for rich messages (requires .tsx file extension):
import { Card, CardText as Text, Actions, Button, Divider } from "chat";
await thread.post(
<Card title="Welcome!">
<Text>Hello! Choose an option:</Text>
<Divider />
<Actions>
<Button id="btn_hello" style="primary">
Say Hello
</Button>
<Button id="btn_info">Show Info</Button>
</Actions>
</Card>,
);
await thread.startTyping();
const result = await generateWithAI(prompt);
await thread.post(result); // Typing indicator clears on post
Use Slack mrkdwn (not standard markdown):
*text*_text_`code`<@USER_ID><#CHANNEL_ID>For detailed Slack patterns, see ./patterns/slack-patterns.md.
Use conventional commits:
feat: add channel search tool
fix: resolve thread pagination issue
test: add unit tests for agent context
docs: update README with setup steps
refactor: extract Slack client utilities
Never commit:
.env filesnode_modules/# Development
pnpm dev # Start dev server on localhost:3000
ngrok http 3000 # Expose local server (separate terminal)
# Quality
pnpm lint # Check linting
pnpm lint --write # Auto-fix lint
pnpm typecheck # TypeScript check
pnpm test # Run all tests
pnpm test:watch # Watch mode
# Build & Deploy
pnpm build # Build for production
vercel # Deploy to Vercel
For detailed guidance, read:
./patterns/testing-patterns.md./patterns/slack-patterns.md./reference/env-vars.md./reference/ai-sdk.md./reference/slack-setup.md./reference/vercel-setup.mdBefore marking ANY task as complete, verify:
pnpm lint passes with no errorspnpm typecheck passes with no errorspnpm test passes with no failuresbot.webhooks"jsx": "react-jsx" and "jsxImportSource": "chat" if using JSX components@ai-sdk/openai and OPENAI_API_KEY is set