AIRGAP StudioAIRGAP Studio

Hooks

AIRGAP Assistant event hook configuration and usage

Overview

Hooks allow you to define commands or scripts that automatically execute when specific events occur in AIRGAP Assistant. By automating repetitive post-processing tasks, you can improve workflow efficiency.

Supported Event Types

EventTrigger TimingExample Use
onSaveAfter the AI saves a fileRun formatter, lint check
onFileCreateAfter the AI creates a new fileAdd file header, update index
onCommitAfter a checkpoint commit is createdUpdate changelog
onTaskStartWhen an AI task startsLoad environment variables, initialize state
onTaskEndWhen an AI task completesResult logging, cleanup tasks

How to Configure Hooks

Add a ## Hooks section within your .airgaprules file to define hooks.

# .airgaprules

## Hooks

### onSave
- If the saved file has a .ts or .tsx extension, run `npx prettier --write`.
- If the saved file has a .py extension, run the `black` formatter.

### onFileCreate
- Add the project license header to new TypeScript files.
- When creating a component file, also generate a test file template in the same directory.

### onTaskEnd
- Record the performed work in CHANGELOG.md.

Hook Execution Behavior

Commands defined in hooks are automatically suggested by the AI when the corresponding event is detected. If auto-approve is not configured, user confirmation is requested before each hook execution.

AI: Saved file utils.ts.
    Run prettier per onSave hook? [Approve/Reject]

Tip: If you allow command execution in Auto Approve settings, hooks will run without separate confirmation. It is recommended to enable auto-approve only for safe commands (formatters, linters, etc.).

Hook Usage Examples

Code Quality Automation

### onSave
- Run code checks and auto-fix fixable issues.
- Run TypeScript type checking and report type errors.

Project Cleanup

### onTaskEnd
- Clean up generated temporary files.
- Output a list and summary of changed files.

Security Considerations

Keep the following in mind when using hooks in air-gapped environments:

  • Verify that commands registered in hooks do not perform unintended actions.
  • Do not register commands that modify system files or require administrator privileges.
  • Always review the hook contents of .airgaprules files obtained from external sources before using them.

Caution: Using rule files from untrusted sources as-is may result in unintended command execution. Always verify hook contents yourself.