main*
📝ai-tools-universal-engine.md
📅September 9, 20256 min read📁ai-tools

Building ai-tools: Universal Configuration for AI Coding Tools

#ai-tools#open-source#typescript#mcp#guardrails#premierstudio

Building ai-tools: Universal Configuration for AI Coding Tools

The Problem

Every team working with AI coding assistants hits the same wall:

  • No unified policy layer. Each tool — Claude Code, Cursor, Codex — has its own format for hooks, MCP servers, rules, and agents. Your configuration gets duplicated, drifts, and breaks silently.
  • No external control plane. If you need to programmatically steer the AI client a developer is using — set boundaries, collect signals, enforce workflow rules — there's no standard way to do it.
  • Fragmented audit trails. Shell commands, file writes, and tool calls are logged in different formats per tool.
  • Inconsistent enforcement. Some tools can block dangerous actions before they happen; others can only observe after the fact.

I built ai-tools to solve this. It's a universal configuration engine with 5 sub-engines that work across every major AI coding tool.

What ai-tools Does

ai-tools gives you a single configuration layer for 5 surfaces:

Loading diagram...

Write your configuration once. Adapters translate it into the native format for each tool you use.

Five Engines

PackageCLIWhat it does
@premierstudio/ai-toolsai-toolsUnified CLI — routes to all engines
@premierstudio/ai-hooksai-hooksHook engine — guardrails, audit trails, runtime control
@premierstudio/ai-mcpai-mcpMCP server configuration management
@premierstudio/ai-agentsai-agentsAgent persona definitions
@premierstudio/ai-skillsai-skillsSlash commands and prompt templates
@premierstudio/ai-rulesai-rulesProject rules with scoping and priority

Supported Tools

ToolHooksMCPAgentsSkillsRules
Claude CodeYesYesYesYesYes
Codex CLIYesYesYes--
Gemini CLIYesYesYesYesYes
CursorYesYesYesYesYes
KiroYesYesYesYesYes
OpenCodeYesYesYesYesYes
ClineYesYesYesYes-
AmpYesYesYes--
Factory DroidYesYesYesYesYes
VS Code / Copilot*YesYesYesYes
ContinueYesYes---
Roo CodeYesYesYesYes-
WindsurfYesYesYes--

*VS Code 1.109+ agent hooks use the Claude Code format.

Quick Start

# Install everything
npm i -D @premierstudio/ai-tools
 
# Detect installed tools, generate configs, install them
ai-tools detect
ai-tools hooks generate && ai-tools hooks install
ai-tools mcp generate && ai-tools mcp install
ai-tools skills generate && ai-tools skills install
ai-tools agents generate && ai-tools agents install
ai-tools rules generate && ai-tools rules install

Or install individual engines:

# Just hooks
npm i -D @premierstudio/ai-hooks
npx ai-hooks init
npx ai-hooks detect --verbose
npx ai-hooks generate
npx ai-hooks install

Hooks Engine

The hooks engine is the most powerful package — an Express.js-style middleware chain for AI tool actions.

Universal Event Model

15 event types across the full AI tool lifecycle:

CategoryBefore (blockable)After (observe-only)
Sessionsession:startsession:end
Promptprompt:submitprompt:response
Tooltool:beforetool:after
Filefile:read, file:write, file:edit, file:delete-
Shellshell:beforeshell:after
MCPmcp:beforemcp:after
System-notification

Built-in Safety Hooks

HookPhaseWhat it does
block-dangerous-commandsbeforeBlocks rm -rf /, DROP DATABASE, fork bombs
scan-secretsbeforeDetects API keys, tokens, private keys in file writes
protect-sensitive-filesbeforePrevents writes to .env, credentials.json, SSH keys
audit-shellafterRecords command, exit code, duration, tool name

Config Example

// ai-hooks.config.ts
import { defineConfig, hook, builtinHooks } from "@premierstudio/ai-hooks";
 
export default defineConfig({
  extends: [{ hooks: builtinHooks }],
  hooks: [
    hook("before", ["shell:before"], async (ctx, next) => {
      if (ctx.event.command.includes("npm publish")) {
        ctx.results.push({ blocked: true, reason: "Publishing is restricted" });
        return;
      }
      await next();
    })
      .id("org:block-publish")
      .name("Block npm publish")
      .priority(10)
      .build(),
  ],
  settings: {
    hookTimeout: 5000,
    failMode: "open",
    logLevel: "warn",
  },
});

Using as a Library

Import the engine directly for building platforms that orchestrate AI agents:

import { HookEngine, builtinHooks } from "@premierstudio/ai-hooks";
 
const engine = new HookEngine({
  hooks: builtinHooks,
  settings: { failMode: "closed" },
});
 
const result = await engine.isBlocked(event, { name: "my-platform", version: "1.0" });
if (result.blocked) {
  console.log(`Blocked: ${result.reason}`);
}

MCP Servers

// ai-mcp.config.ts
import { defineConfig } from "@premierstudio/ai-mcp";
 
export default defineConfig({
  servers: [
    {
      name: "filesystem",
      command: "npx",
      args: ["-y", "@modelcontextprotocol/server-filesystem", "./src"],
      transport: "stdio",
    },
  ],
});

Rules

// ai-rules.config.ts
import { defineRulesConfig } from "@premierstudio/ai-rules";
 
export default defineRulesConfig({
  rules: [
    {
      name: "typescript-strict",
      content: "Always use strict TypeScript. No `any` types.",
      scope: "always",
      priority: 1,
    },
    {
      name: "test-conventions",
      content: "Co-locate tests as *.test.ts next to source files.",
      scope: "glob",
      globs: ["**/*.test.ts"],
    },
  ],
});

What's Next

  • More adapters for emerging tools
  • Event replay and auditing
  • Integration with more platforms

Links: