Neovim Hooks

Akto Guardrails for Neovim provides security validation and observability for AI plugin interactions directly inside Neovim. It intercepts LLM API calls made by Neovim AI plugins, validates prompts against security policies, blocks risky behavior, and reports all events to your Akto dashboard — without proxying or redirecting traffic.

Key Features

  • Zero Proxy - Plugins always talk to LLM APIs directly; no traffic redirection

  • Broad Plugin Coverage - Covers 7 major Neovim AI plugins out of the box

  • Transparent Integration - Hooks into each plugin's native HTTP/LSP mechanism

  • Real-time Protection - Blocks prompts before they reach the LLM in sync mode

  • Centralized Monitoring - All events reported to Akto dashboard

  • Flexible Deployment - Sync (blocking) or async (observability) modes

  • Selective Coverage - Enable or disable hooks per plugin

Supported Plugins

Plugin
Stars
Hook Module
How It Works

avante.nvim

17.7k

plenary_hook

Wraps plenary.curl

copilot.vim

11.5k

copilot_vim_hook

Wraps _copilot.lsp_request

codecompanion.nvim

6.4k

plenary_hook

Wraps plenary.curl

windsurf.vim

5.1k

windsurf_hook

Wraps vim.fn.jobstart + chansend

copilot.lua

4.0k

copilot_hook

Wraps copilot.api.request

ChatGPT.nvim

4.0k

plenary_hook

Wraps plenary.job

CopilotChat.nvim

3.6k

plenary_hook

Wraps plenary.curl

How It Works

The Akto Neovim plugin wraps the HTTP and LSP functions each AI plugin uses internally. When a plugin makes an LLM API call:

Two Operating Modes:

  1. Sync mode (sync_mode = true, default) — Guardrails run before the LLM call. Blocked prompts never reach the LLM. Adds latency equal to the guardrails check.

  2. Async mode (sync_mode = false) — LLM call goes through immediately. Guardrails and ingestion happen asynchronously after the call. Best for observability without blocking.

Monitored LLM APIs:

The plenary hook intercepts calls to the following API hosts:

  • api.openai.com

  • api.anthropic.com

  • generativelanguage.googleapis.com

  • api.cohere.ai

  • api.mistral.ai

  • api.groq.com

  • openrouter.ai

File Structure

Key Files:

  • init.lua: Entry point — require("akto").setup(...) configures and activates all hooks

  • http.lua: Shared payload builder and Akto API communication; used by all hook modules

  • plenary_hook.lua: Intercepts plenary.curl (avante, codecompanion, CopilotChat) and plenary.job (ChatGPT.nvim); supports both sync and async modes

  • copilot_hook.lua: Intercepts copilot.api.request for copilot.lua; ingestion-only

  • copilot_vim_hook.lua: Intercepts _copilot.lsp_request for copilot.vim; ingestion-only

  • windsurf_hook.lua: Intercepts vim.fn.jobstart + chansend for Codeium/windsurf.vim; ingestion-only

  • events.lua: Registers autocmd listeners for plugin-level events (CodeCompanion, CopilotChat, avante)

Setup Guide

Prerequisites

  • Neovim 0.9+

  • curl on PATH (used for Akto backend calls)

  • Akto instance running and accessible (e.g. https://your-akto-instance.com)

Installation Steps

1

Create Plugin Directory

2

Download Plugin Files

3

Add to Your Neovim Config

Add the following to your ~/.config/nvim/init.lua after your plugin manager setup:

circle-exclamation
4

Configure Hook Behavior (Optional)

Customize which hooks are active and how they behave:

Mode Options:

  • sync_mode = true (default): Guardrails check runs synchronously before LLM call. Blocked prompts never reach the LLM.

  • sync_mode = false: LLM call proceeds immediately. Guardrails and ingestion happen asynchronously. Use for observability without blocking.

5

Restart Neovim

On startup you should see a notification:

6

Verify Installation

Run the status command inside Neovim:

Expected output:

Test by using any supported AI plugin. Akto will validate the prompt and ingest the interaction.

Configuration Reference

Setup Options

Disabling Specific Hooks

Neovim Commands

Command
Description

:AktoEnable

Enable all hooks (re-enables after :AktoDisable)

:AktoDisable

Disable all hooks, restoring original plugin functions

:AktoStatus

Show current state, mode, and per-hook configuration

Hook Behavior by Plugin

Plugin
Hook Module
Blocking Support
Ingestion

avante.nvim

plenary_hook

✅ (sync mode)

codecompanion.nvim

plenary_hook

✅ (sync mode)

CopilotChat.nvim

plenary_hook

✅ (sync mode)

ChatGPT.nvim

plenary_hook

✅ (sync mode)

copilot.lua

copilot_hook

❌ (ingestion only)

copilot.vim

copilot_vim_hook

❌ (ingestion only)

windsurf.vim

windsurf_hook

❌ (ingestion only)

Note: copilot.lua, copilot.vim, and windsurf.vim hooks intercept at the LSP/process level and operate in ingestion-only mode regardless of sync_mode.

Troubleshooting

Plugin Not Loading

No Events in Dashboard

Hook Not Intercepting Calls

Ensure require("akto").setup(...) is called after your plugin manager loads AI plugins. If a plugin was already loaded before setup, run :AktoDisable then :AktoEnable to re-wrap.

Blocked Requests Not Showing Notification

Ensure events = true in your setup config. The autocmd listeners register block notifications for CodeCompanion, CopilotChat, and avante.

Slow Response / High Latency

Switch to async mode to remove guardrails latency from the LLM call path:

Uninstallation

To completely remove Akto Neovim hooks:

Complete Removal

Selective Removal (Keep Files, Disable)

Add enabled = false or simply remove the setup call from your config. The plugin files remain on disk but are not loaded.

Alternatively, use the Neovim command while running:

This restores all original plugin functions for the current session without removing files.

Backup Before Removal

Verify Removal

Restore to Default

After uninstallation, all AI plugins will operate without Akto security monitoring. No additional configuration is needed beyond removing the files and the setup call.

Enterprise Deployment

Automated Deployment Script

Deploy to developers:

Quick Setup Summary

Resources

Last updated