一键导入
cc-sessions-hooks
Specialized guidance for creating, modifying, and debugging cc-sessions hooks that enforce DAIC discipline, write-gating, and framework integrity
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Specialized guidance for creating, modifying, and debugging cc-sessions hooks that enforce DAIC discipline, write-gating, and framework integrity
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Execute comprehensive framework health checks to validate core cc-sessions functionality including write-gating, state persistence, skill precedence, LCMP freshness, and handoff log structure
Specialized guidance for developing cc-sessions API commands and subsystems for state management, task operations, configuration, and protocol execution
Provide comprehensive guidance for developing and maintaining the cc-sessions framework core functionality - primary skill for hooks, sessions, tasks, middleware, route handlers, and API endpoints
Natural language wrapper for checkpoint commands - automatically triggers /checkpoint:create, /checkpoint:restore, /checkpoint:list when users request checkpoint operations
Natural language wrapper for code review - automatically triggers /code-review when users express intent to review code, check for bugs, or validate code quality
Natural language wrapper for ContextKit planning commands - automatically triggers /ctxk:plan commands when users request planning assistance
| name | cc-sessions-hooks |
| description | Specialized guidance for creating, modifying, and debugging cc-sessions hooks that enforce DAIC discipline, write-gating, and framework integrity |
| schema_version | 1 |
Type: WRITE-CAPABLE DAIC Modes: IMPLEMENT only Priority: High
This skill activates on:
sessions/hooks/**/*.jsFrom: skill-rules.json - cc-sessions-hooks configuration
Specialized guidance for creating, modifying, and debugging cc-sessions hooks. Hooks are the enforcement layer that ensures DAIC discipline, write-gating, and framework integrity.
When activated in IMPLEMENT mode with an active cc-sessions task:
Hook Types & Purposes
UserPromptSubmit Hook:
PreToolUse Hook:
PostToolUse Hook:
SessionStart Hook:
Hook Development Patterns
Basic Hook Structure:
// sessions/hooks/example_hook.js
module.exports = {
name: 'example_hook',
description: 'Brief description of what this hook does',
async execute(context) {
// Hook logic here
// Return { success: true } or { success: false, error: 'message' }
}
};
Enforcement Hook Pattern:
async execute(context) {
const { toolName, toolParams, sessionState } = context;
// Check conditions
if (shouldBlock(toolName, sessionState)) {
return {
success: false,
error: 'Tool blocked: [reason]',
additionalContext: '[guidance for user]'
};
}
return { success: true };
}
Write-Gating Enforcement
The sessions_enforce.js hook is CRITICAL for framework integrity:
What it enforces:
How to extend:
WRITE_TOOLS arraycheckWriteGating()Shared State Access
Hooks can read/modify shared state:
const state = require('../sessions-state.json');
const fs = require('fs');
// Read state
const currentMode = state.mode;
const activeTask = state.task;
// Modify state (carefully!)
state.flags.contextWarning85 = true;
fs.writeFileSync(
path.join(__dirname, '../sessions-state.json'),
JSON.stringify(state, null, 2)
);
Hook Execution Order
Understand execution flow:
Hooks execute synchronously within their phase.
CRITICAL WRITE-GATING RULES:
Hook-Specific Safety:
{ success: true/false } from execute()State Mutation Safety:
✓ "Add a hook to validate task manifest format" ✓ "Fix the sessions_enforce.js write-gating for MultiEdit tool" ✓ "Create a PostToolUse hook to log all file modifications" ✓ "Modify UserPromptSubmit to detect '/squish' command" ✓ "Debug why the IMPLEMENT mode transition isn't triggering"
✗ In DISCUSS/ALIGN/CHECK mode (hook development requires IMPLEMENT) ✗ No active cc-sessions task (violates write-gating) ✗ User wants to create non-hook cc-sessions code (use cc-sessions-core) ✗ Changes would weaken enforcement mechanisms
Before deploying a new or modified hook:
{ success, error? } structureif (invalidCondition) {
return {
success: false,
error: '[CATEGORY: Clear Error Message]',
additionalContext: 'What user should do instead'
};
}
if (warningCondition) {
console.warn('[Hook Warning]', message);
// Continue execution
}
return { success: true };
const state = loadState();
state.flags.someFlag = true;
saveState(state);
return { success: true };
if (context.toolName === 'Write' && context.sessionState.mode !== 'IMPLEMENT') {
return { success: false, error: 'Write only in IMPLEMENT mode' };
}
When creating or modifying hooks, log in context/decisions.md:
### Hook Change: [Date]
- **Hook:** sessions/hooks/sessions_enforce.js
- **Change:** Added MultiEdit to WRITE_TOOLS array
- **Rationale:** MultiEdit can write to multiple files, needs same gating as Write/Edit
- **Testing:** Verified blocks in DISCUSS, allows in IMPLEMENT
- **Risk:** Low (additive change, follows existing pattern)
Last Updated: 2025-11-15 Framework Version: 2.0