关于 crisis-response-protocol
为 AI 心理辅导系统提供危机干预实现指南,面向开发恢复与心理健康功能的团队。内容涵盖分级风险评估、应对流程和安全资源,并强调 AI 不能取代人工支持。
主要功能
- 01危机风险分级检测
- 02分级响应协议
- 03危机资源展示
- 04紧急联系人通知
- 05事件审计与测试
适用场景
- 01为聊天系统加入危机升级流程
- 02构建安全计划与风险评估界面
- 03向用户展示热线和紧急资源
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ curiositech/ some_claude_skills --skill crisis-response-protocol安装后在 Claude Code 中输入/crisis-response-protocol确认已加载。
附带文件.claude-plugin/plugin.json
详细介绍
危机应对协议
此技能可帮助你按照心理健康最佳实践,为 AI 辅导系统实现安全的危机干预功能。
适用场景
✅ 在以下情况下使用此技能:
- 在戒瘾/心理健康应用中实现危机检测
- 构建安全规划功能
- 集成热线和紧急资源展示
- 设计风险评估界面
- 为 AI 聊天系统创建升级处理协议
❌ 请勿用于:
- 亲自应对正在发生的危机 → 拨打 988 或联系紧急服务
- 一般心理健康内容 → 使用
sober-addict-protector或recovery-coach-patterns - 医疗建议或诊断 → 始终交由持证专业人士处理
- 替代人工危机辅导员 → AI 应提供辅助,绝不能取而代之
关键安全原则
在急性危机情况下,AI 绝不能成为唯一的应对方。 始终提供获得人工支持和紧急服务的途径。
危机检测
风险指标类别
interface RiskIndicators {
// PRIMARY - Immediate escalation required
primary: {
suicidalIdeation: string[]; // "want to die", "end it all"
selfHarmIntent: string[]; // "hurt myself", "cutting"
homicidalIdeation: string[]; // "hurt someone"
activeSubstanceEmergency: string[]; // "overdosed", "can't stop"
};
// SECONDARY - Elevated monitoring
secondary: {
severeDepression: string[]; // "hopeless", "no point"
panicSymptoms: string[]; // "can't breathe", "heart racing"
psychoticSymptoms: string[]; // "hearing voices"
severeAnxiety: string[]; // "terrified", "losing control"
};
// TERTIARY - Check-in triggers
tertiary: {
isolationPatterns: string[]; // "no one cares", "alone"
substanceRelapse: string[]; // "started using", "slipped"
hopelessness: string[]; // "never get better"
};
}
检测实现
// src/lib/ai/crisis-detection.ts
export interface CrisisAssessment {
level: 'none' | 'low' | 'medium' | 'high' | 'critical';
indicators: string[];
recommendedAction: CrisisAction;
timestamp: Date;
}
export type CrisisAction =
| 'continue_conversation'
| 'gentle_check_in'
| 'safety_resources'
| 'crisis_protocol'
| 'emergency_escalation';
export function assessCrisisLevel(
messageContent: string,
conversationHistory: Message[],
userCheckInHistory: CheckIn[]
): CrisisAssessment {
const indicators: string[] = [];
let level: CrisisAssessment['level'] = 'none';
// Check primary indicators (critical)
if (hasPrimaryIndicators(messageContent)) {
level = 'critical';
indicators.push('primary_risk_detected');
}
// Check secondary indicators
if (hasSecondaryIndicators(messageContent)) {
level = level === 'none' ? 'high' : level;
indicators.push('secondary_risk_detected');
}
// Check pattern indicators from history
if (hasWorseningPattern(userCheckInHistory)) {
level = level === 'none' ? 'medium' : level;
indicators.push('worsening_trend');
}
// Check conversation escalation
if (hasEscalatingDistress(conversationHistory)) {
level = level === 'none' ? 'medium' : level;
indicators.push('escalating_distress');
}
return {
level,
indicators,
recommendedAction: getRecommendedAction(level),
timestamp: new Date(),
};
}
分级响应协议
级别 1:继续对话(无危机)
正常的 AI 辅导互动。
级别 2:温和询问(低风险)
const gentleCheckInResponse = `
I want to make sure I understand how you're feeling.
It sounds like you're going through a difficult time.
Would you like to:
- Talk more about what's on your mind?
- Try a grounding exercise together?
- Look at some coping strategies?
I'm here to listen.
`;
级别 3:安全资源(中等风险)
const safetyResourcesResponse = `
I hear that you're struggling, and I want you to know that support is available.
Here are some resources that might help:
📞 988 Suicide & Crisis Lifeline: Call or text 988
💬 Crisis Text Line: Text HOME to 741741
🌐 SAMHSA Helpline: 1-800-662-4357
Would you like to talk about what's going on, or would connecting with one of these resources feel right?
`;
级别 4:危机协议(高风险)
const crisisProtocolResponse = `
I'm concerned about what you've shared, and I want to make sure you're safe.
Right now, I'd like you to consider reaching out to someone who can help:
🆘 If you're in immediate danger: Call 911
📞 988 Suicide & Crisis Lifeline: Call or text 988 (24/7)
💬 Crisis Text Line: Text HOME to 741741
These are trained counselors who understand what you're going through.
Is there someone you trust - a friend, family member, or sponsor - who you could reach out to right now?
I'm still here with you.
`;
级别 5:紧急升级处理(危急)
const emergencyResponse = `
I'm very concerned about your safety right now.
🆘 Please call 911 or go to your nearest emergency room immediately.
If you can't do that, please call 988 right now - they can help.
Your life matters. Please reach out for help right now.
[EMERGENCY CONTACTS DISPLAYED]
`;
// System action: Flag for human review, notify emergency contact if configured
在聊天处理程序中实现
// src/lib/ai/chat-handler.ts
export async function handleChatMessage(
message: string,
conversationId: string,
userId: string
): Promise<ChatResponse> {
// 1. Assess crisis level BEFORE generating AI response
const crisisAssessment = await assessCrisisLevel(
message,
await getConversationHistory(conversationId),
await getUserCheckIns(userId, 7)
);
// 2. Log assessment (for safety review)
await logCrisisAssessment(userId, conversationId, crisisAssessment);
// 3. Handle based on level
if (crisisAssessment.level === 'critical') {
// Don't use AI - provide immediate crisis response
await notifyEmergencyContact(userId);
await flagForHumanReview(conversationId, 'critical_crisis');
return {
message: emergencyResponse,
showEmergencyContacts: true,
disableChat: true, // Prevent further AI interaction
crisisLevel: 'critical',
};
}
if (crisisAssessment.level === 'high') {
// Provide crisis resources, continue with caution
await flagForHumanReview(conversationId, 'high_risk');
return {
message: crisisProtocolResponse,
showCrisisResources: true,
crisisLevel: 'high',
};
}
// 4. For lower levels, proceed with AI but inject safety context
const systemPrompt = getSystemPromptWithSafetyContext(crisisAssessment);
const aiResponse = await generateAIResponse(message, systemPrompt);
// 5. Post-process AI response for safety
const safeResponse = await validateResponseSafety(aiResponse);
return {
message: safeResponse,
crisisLevel: crisisAssessment.level,
};
}
安全资源数据库
// src/lib/crisis/resources.ts
export const crisisResources = {
national: [
{
name: '988 Suicide & Crisis Lifeline',
phone: '988',
text: '988',
url: 'https://988lifeline.org',
available: '24/7',
description: 'Free, confidential crisis support',
},
{
name: 'Crisis Text Line',
text: 'HOME to 741741',
url: 'https://www.crisistextline.org',
available: '24/7',
description: 'Text-based crisis support',
},
{
name: 'SAMHSA National Helpline',
phone: '1-800-662-4357',
url: 'https://www.samhsa.gov/find-help/national-helpline',
available: '24/7',
description: 'Substance abuse and mental health referrals',
},
],
recovery: [
{
name: 'AA Hotline',
phone: '1-800-839-1686',
url: 'https://www.aa.org',
description: 'Alcoholics Anonymous support',
},
{
name: 'NA Helpline',
phone: '1-818-773-9999',
url: 'https://na.org',
description: 'Narcotics Anonymous support',
},
],
specialized: [
{
name: 'Veterans Crisis Line',
phone: '988 (press 1)',
text: '838255',
description: 'For veterans and service members',
},
{
name: 'Trevor Project',
phone: '1-866-488-7386',
text: 'START to 678-678',
description: 'LGBTQ+ youth crisis support',
},
],
};
紧急联系人系统
// src/lib/crisis/emergency-contacts.ts
export async function notifyEmergencyContact(userId: string): Promise<void> {
const contacts = await getEmergencyContacts(userId);
if (contacts.length === 0) {
// Log that no emergency contact was available
await logCrisisEvent(userId, 'no_emergency_contact');
return;
}
const primaryContact = contacts[0];
// Send notification (SMS, email, or push)
await sendEmergencyNotification(primaryContact, {
type: 'crisis_alert',
message: `${userName} may be in crisis and could use your support. ` +
`Please reach out to them if you can.`,
// Never include conversation content - privacy
});
// Audit log
await logCrisisEvent(userId, 'emergency_contact_notified', {
contactId: primaryContact.id,
});
}
AI 安全防护措施
// Prompt injection for safety context
const safetySystemPrompt = `
CRITICAL SAFETY INSTRUCTIONS:
1. You are NOT a therapist or crisis counselor
2. For ANY mention of self-harm, suicide, or harming others:
- Express genuine concern
- Provide crisis resources (988, Crisis Text Line)
- Encourage professional help
- Do NOT attempt to counsel through crisis
3. Never minimize feelings or use toxic positivity
4. Never promise confidentiality about safety concerns
5. Always validate emotions while encouraging professional support
6. If user mentions relapse, acknowledge and provide SAMHSA helpline
`;
// Response validation
async function validateResponseSafety(response: string): Promise<string> {
const unsafePatterns = [
/don't (call|reach out|get help)/i,
/you don't need (help|therapy|a professional)/i,
/just (think positive|be happy|get over it)/i,
/it's not that (bad|serious)/i,
];
for (const pattern of unsafePatterns) {
if (pattern.test(response)) {
// Flag for review and return safe fallback
await flagForReview('unsafe_response_pattern');
return getSafeFallbackResponse();
}
}
return response;
}
审计与合规
// All crisis events must be logged for review
export async function logCrisisEvent(
userId: string,
eventType: CrisisEventType,
details?: Record<string, unknown>
): Promise<void> {
await db.insert(crisisEvents).values({
id: generateId(),
userId,
eventType,
details: JSON.stringify(sanitizeDetails(details)),
createdAt: new Date(),
reviewed: false, // Requires human review
});
// Critical events trigger immediate notification
if (isCriticalEvent(eventType)) {
await notifyOnCallStaff(userId, eventType);
}
}
测试危机功能
// NEVER use real crisis content in tests
describe('Crisis Detection', () => {
it('detects high-risk indicators', () => {
// Use clearly artificial test phrases
const result = assessCrisisLevel(
'[TEST_HIGH_RISK_INDICATOR]',
[],
[]
);
expect(result.level).toBe('high');
});
it('provides appropriate resources', () => {
const response = getCrisisResponse('high');
expect(response).toContain('988');
expect(response).toContain('Crisis Text Line');
});
});
参考资料
评论
支持 Markdown