M0X Docs
M0X Docs

Get Started

Quickstart GuideCore ConceptsAI ModelsPricing Plans

Core Features

Feature OverviewThe CoderX AgentOperating ModesReviewTerminal IntegrationBrowserSecurity

Customization

Lifecycle HooksContext ManagementRules & InstructionsCommandsSkills & Custom ToolsSub-Agents & Parallel OrchestrationSemantic Search@ Mentions

MCP

Model Context Protocol (MCP)MCP FeaturesMCP Tab

Tools

Cloud FeaturesCLIInline Edit (Ctrl+K)BugbotShared TranscriptsSlack IntegrationLinear IntegrationGitHub IntegrationGit SupportGitLab IntegrationDeep Links

Settings

ConfigurationIgnore FilesExtensionsKeyboard ShortcutsShell Commands

Advanced

Parallel AgentsBring Your Own Key (BYOK)Language SupportMigrations

Account

Account ManagementBilling & SubscriptionsUpdate AccessTeamsEnterprise

Guides

CookbookAgent WorkflowsWeb DevelopmentData ScienceLarge Codebases & MonoreposMermaid DiagramsBugbot Rules

Support

TroubleshootingCommon IssuesRequest IDTroubleshooting GuideDownload
Documentation

Lifecycle Hooks

Automate formatting, linting, auditing, and notifications using lifecycle triggers.

Lifecycle hooks allow you to execute shell scripts automatically before or after specific agent events (such as after editing a file, compiling the project, or finishing a task loop). This helps automate formatting, testing, and team notifications without manual intervention.


Supported Event Triggers

You can subscribe scripts to the following lifecycle events:

Event NameTrigger ConditionCommon Use Case
on_edit_completeFires immediately after the agent modifies any file.Run Prettier/Linter on the edited files.
on_agent_completeFires when the agent achieves its task goal successfully.Run a build, run test coverage, or commit changes.
pre_execution_auditFires before the agent writes changes.Scan diff files for open keys or credentials.
on_command_failFires if a command executed in the terminal fails.Notify on slack or generate diagnostic dumps.

Configuring Hooks (.m0x/hooks.json)

To enable hooks, create a folder named .m0x/ in the root of your workspace, and add a hooks.json file inside it:

.m0x/hooks.json
{
  "hooks": [
    {
      "event": "on_edit_complete",
      "command": "npx prettier --write",
      "args": ["${file_path}"]
    },
    {
      "event": "on_agent_complete",
      "command": "git add ${workspace_root} && git commit -m 'chore: updates by CoderX agent'"
    }
  ]
}

Environment Variables Injected to Hooks

When a hook is executed, CoderX injects context-specific variables that you can reference in your command arguments:

  • ${file_path}: The absolute path of the file that was modified (available in on_edit_complete).
  • ${workspace_root}: The root path of the active workspace.
  • ${task_goal}: The string description of the agent's objective.
  • ${exit_code}: The return code of the failed command (available in on_command_fail).

Creating a Pre-Commit Lint Hook

To ensure the agent only produces syntactically correct code that passes lint requirements before merging:

Create Config Directory

Create a folder named .m0x in your workspace root.

Define Hook Actions

Create .m0x/hooks.json and add a script for on_edit_complete to run npm run lint -- --fix on modified files.

Verification

Run a task with the agent. You will see the linter running in the background console after each file modification, keeping your workspace clean.

Security

Enterprise-grade security and privacy.

Context Management

Learn how to manage the files, symbols, and codebase resources the AI sees.

On this page

Supported Event TriggersConfiguring Hooks (.m0x/hooks.json)Environment Variables Injected to HooksCreating a Pre-Commit Lint HookCreate Config DirectoryDefine Hook ActionsVerification