Get the FREE Ultimate OpenClaw Setup Guide →

new-adapter

Scanned
npx machina-cli add skill lbb00/ai-rules-sync/new-adapter --openclaw
Files (1)
SKILL.md
2.4 KB

New Adapter

Instructions

Complete workflow for adding support for a new AI tool to AIS.

Prerequisites

Before starting, gather this information:

  • Tool name (e.g., "windsurf", "mcp")
  • Rule/config types supported (e.g., rules, commands, skills)
  • Default source directory (e.g., .windsurf/rules/)
  • Target directory (usually same as source)
  • File mode: file or directory

Steps

1. Create Adapter File

Create src/adapters/<tool>-<type>.ts:

import { createBaseAdapter } from './base.js';

export const myToolAdapter = createBaseAdapter({
  name: '<tool>-<type>',
  tool: '<tool>',
  subtype: '<type>',
  configPath: ['<tool>', '<type>'],
  defaultSourceDir: '.<tool>/<type>',
  targetDir: '.<tool>/<type>',
  mode: 'directory', // or 'file'
});

2. Register Adapter

In src/adapters/index.ts:

  • Import the new adapter
  • Register in DefaultAdapterRegistry constructor

3. Update Project Config

In src/project-config.ts:

  • Add tool section to ProjectConfig interface
  • Add tool to SourceDirConfig interface if needed

4. Wire CLI Commands

In src/cli/register.ts:

  • Add tool subcommand group
  • Register add/remove/install/import commands

5. Update Completion

In src/completion.ts:

  • Add tool to completion types
  • Add subtype completions

In src/completion/scripts.ts:

  • Update bash/zsh/fish completion scripts

6. Add Tests

Create src/__tests__/<tool>-<type>.test.ts:

  • Test adapter properties
  • Test add/remove operations
  • Test config path resolution

7. Update Documentation

  • README.md: Add to supported sync types table
  • README_ZH.md: Sync changes (use /sync-readme)
  • CLAUDE.md: Update if architectural changes

8. Verify

# Build
npm run build

# Run tests
npm test

# Test manually
node dist/index.js <tool> <type> add <name>
node dist/index.js <tool> <type> remove <name>

Checklist

  • Adapter file created
  • Adapter registered
  • ProjectConfig updated
  • CLI commands wired
  • Completion updated
  • Tests written and passing
  • README.md updated
  • README_ZH.md synced
  • Manual testing complete

Examples

Request: Add support for a new AI tool with rules and skills Result: Complete adapter implementation with tests passing

Source

git clone https://github.com/lbb00/ai-rules-sync/blob/main/.claude/skills/new-adapter/SKILL.mdView on GitHub

Overview

New Adapter provides a repeatable workflow to add support for a new AI tool to AIS. It covers creating the adapter file, registering it, updating project configuration, wiring CLI commands and completion, adding tests, and updating docs.

How This Skill Works

You create an adapter file at src/adapters/<tool>-<type>.ts using createBaseAdapter, then register the adapter in src/adapters/index.ts. The workflow continues by updating ProjectConfig and any necessary SourceDirConfig, wiring the CLI commands, updating completion scripts, adding tests, and refreshing documentation before building and verifying the integration.

When to Use It

  • When adding support for a new AI tool to AIS (new tool, new adapter).
  • When introducing a new rule/config type (rules, commands, skills) for an existing tool.
  • When implementing CLI commands and completion for a new adapter.
  • When adding tests for adapter properties, add/remove operations, and config path resolution.
  • When updating documentation to reflect the new adapter and its usage.

Quick Start

  1. Step 1: Create src/adapters/<tool>-<type>.ts using createBaseAdapter with proper tool, type, and paths.
  2. Step 2: Register the new adapter in src/adapters/index.ts and ensure CLI/completion wiring is updated.
  3. Step 3: Build, run tests, and verify manually with npm run build, npm test, and node dist/index.js <tool> <type> add <name>.

Best Practices

  • Clearly define the tool name and type in the adapter configuration.
  • Match defaultSourceDir and targetDir to the chosen tool/type paths.
  • Decide early between file vs directory mode and document it in the adapter.
  • Write tests for adapter properties, add/remove operations, and config path resolution.
  • Run a full build and test cycle (npm run build, npm test) and perform manual checks.

Example Use Cases

  • Add windsurf-rules adapter with CLI and tests
  • Add mcp-commands adapter with completion support
  • Add acme-tool-skills adapter and wire config
  • Add mytool-file adapter for a single-file config
  • Add datax-tool-rules adapter and test config path resolution

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers