Passo-a-passo detalhado do skill, referenciando as fases cognitivas:
1SENSE — Identificar contexto e urgência
Definir canal: `#deployments` (informativo), `#alerts-critical` (urgente), `#approvals` (workflow)
Verificar se usa Incoming Webhook ou Bot Token
2RECOMMEND — Mensagem simples com webhook
```typescript
// lib/notifications/slack.ts
export async function notifySlack({
title, message, color = '#00b894', channel, fields,
}: SlackNotification) {
const response = await fetch(process.env.SLACK_WEBHOOK_URL!, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
channel,
attachments: [{
color,
blocks: [
{
type: 'section',
text: { type: 'mrkdwn', text: `*${title}*\n${message}` },
},
fields && {
type: 'section',
fields: fields.map(({ label, value }) => ({
type: 'mrkdwn', text: `*${label}*\n${value}`,
})),
},
{ type: 'context', elements: [{
type: 'mrkdwn', text: `<!date^${Math.floor(Date.now()/1000)}^{date_short_pretty} at {time}|now>`,
}]},
].filter(Boolean),
}],
}),
});
if (!response.ok) throw new Error(`Slack error: ${response.status}`);
}
```
3RECOMMEND — Alerta de deploy com botões (Block Kit)
```typescript
await notifyDeployApproval({
service: 'skillschain-site',
version: 'v1.2.3',
environment: 'production',
deployer: 'THIAGONOMA',
previewUrl: 'https://staging.synapticskills.ai',
});
// Gera mensagem com botões Approve/Reject
// Usa Slack Bolt para capturar a interação do botão
```
4RECOMMEND — Retry com backoff
```typescript
async function sendWithRetry(payload: object, maxRetries = 3): Promise<void> {
for (let attempt = 0; attempt <= maxRetries; attempt++) {
const res = await fetch(webhookUrl, { method: 'POST', body: JSON.stringify(payload) });
if (res.ok) return;
if (res.status === 429) {
const retryAfter = Number(res.headers.get('Retry-After') ?? 1);
await new Promise(r => setTimeout(r, retryAfter * 1000));
continue;
}
if (attempt === maxRetries) throw new Error(`Failed after ${maxRetries} retries`);
await new Promise(r => setTimeout(r, 2 ** attempt * 1000)); // exponential backoff
}
}
```
5EVALUATE — Testar em canal de teste
```bash
# Enviar mensagem de teste
curl -X POST $SLACK_WEBHOOK_URL \
-H 'Content-type: application/json' \
-d '{"text": "🧪 Teste de notificação do sistema"}'
```
6REFLECT — Documentar e monitorar
Criar runbook: quais alertas existem, o que cada um significa, quem é responsável
Configurar fallback: se Slack falhar, enviar para email ou PagerDuty
Reportar telemetria via mcp-skillschain