Rules, Workflows & Hooks
Customizing AI behavior with project rules, workflows, and hooks
Rules
Rules are instructions for the AI that apply to your entire project. They define coding style, architectural decisions, and constraints.
Where they live
Create a .skycoderules file (or a .skycoderules/ directory with multiple rule files) in the project root.
Global rules (for all projects) are stored in ~/Documents/Skycode/Rules/.
Example
- Use TypeScript
- Components in src/components/
- Styling: Tailwind CSS
- No console.log in production code
- Tests next to files (*.test.ts)
Management
Rules can be enabled/disabled through the management panel: click the rules icon in chat → "Rules" tab.
Skycode automatically picks up changes to rule files on each new message.
Workflows
Workflows are pre-written instruction sequences that can be invoked with /workflow-name in chat.
Where they live
.skycoderules/workflows/ — each file is one workflow.
Global workflows: ~/Documents/Skycode/Workflows/.
Example
File .skycoderules/workflows/new-component:
1. Create a React component in src/components/
2. Add Props types
3. Write a test next to it (*.test.tsx)
4. Export from index.ts
Invocation
Type in chat: /new-component ButtonGroup — the AI will execute all steps.
Management
Workflows can be enabled/disabled through the panel: rules icon → "Workflows" tab.
Hooks
Hooks are scripts that automatically run on certain AI events.
Where they live
.skycoderules/hooks/ — each file is one hook. The file name is the event name.
Global hooks: ~/Documents/Skycode/Hooks/.
Available Events
| Event | When it triggers |
|---|---|
| PreToolUse | Before an AI tool executes |
| PostToolUse | After an AI tool executes |
| UserPromptSubmit | When the user sends a message |
| TaskStart | When a new task starts |
| TaskResume | When a task is resumed |
| TaskCancel | When a task is cancelled |
| TaskComplete | When a task completes |
| PreCompact | Before context compaction |
Example
File .skycoderules/hooks/PostToolUse:
#!/bin/bash
# Run linter after every AI action
cd "$WORKSPACE_ROOT"
npm run lint --fix 2>/dev/null
echo '{"cancel": false}'
The hook receives JSON on stdin and must return JSON on stdout:
{
"cancel": false,
"contextModification": "Optional context for AI",
"errorMessage": ""
}
cancel: true— cancels the current actioncontextModification— adds text to AI context (max 50 KB)- Execution timeout: 30 seconds
Management
Hooks can be enabled/disabled through the panel: rules icon → "Hooks" tab.
Windows: On Windows, hooks are executed through the shell. Hook files should have no extension (like git hooks).