agentleFS
suyashb734suyashb734/cliagents/.claude/skills/adding-adapters/SKILL.md

adding-adapters

Skill19 starsChanged 7 months agoMITView on GitHub

Guide for adding new CLI adapters to cliagents. Use when creating a new adapter for a CLI tool like Claude Code, Gemini CLI, Codex, etc.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Create adapter file: src/adapters/my-cli.js

    line 11
  2. Very specific:

    Add to MODEL_MAP in src/server/openai-compat.js

    line 15
  3. Very specific:

    Add test in tests/run-all.js:

    line 92

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Adding New Adapters to cliagents

Quick Start

  1. Create adapter file: src/adapters/my-cli.js
  2. Extend BaseLLMAdapter class
  3. Implement required methods
  4. Register in src/server/index.js
  5. Add to MODEL_MAP in src/server/openai-compat.js

Adapter Template

const BaseLLMAdapter = require('../core/base-llm-adapter');
const { spawn } = require('child_process');

class MyCliAdapter extends BaseLLMAdapter {
  constructor(config = {}) {
    super(config);
    this.name = 'my-cli';
    this.timeout = config.timeout || 120000;
  }

  async isAvailable() {
    // Check if CLI is installed
    try {
      const { execSync } = require('child_process');
      execSync('which my-cli', { stdio: 'ignore' });
      return true;
    } catch {
      return false;
    }
  }

  getAvailableModels() {
    return ['model-1', 'model-2'];
  }

  async *send(sessionId, message, options = {}) {
    // Implement streaming response
    const process = spawn('my-cli', ['--prompt', message]);

    for await (const chunk of process.stdout) {
      yield {
        type: 'progress',
        progressType: 'assistant',
        content: chunk.toString()
      };
    }

    yield { type: 'result', content: fullResponse };
  }

  async terminate(sessionId) {
    // Cleanup
  }
}

module.exports = MyCliAdapter;

Required Methods

MethodPurpose
isAvailable()Check if CLI is installed
getAvailableModels()Return list of supported models
send(sessionId, message, options)Async generator yielding response chunks
terminate(sessionId)Cleanup resources

Registration

In src/server/index.js:

const MyCliAdapter = require('../adapters/my-cli');
this.sessionManager.registerAdapter('my-cli', new MyCliAdapter(options.myCli || {}));

In src/server/openai-compat.js MODEL_MAP:

'my-model': { adapter: 'my-cli', model: 'model-1' },

Testing

Add test in tests/run-all.js:

await testAdapter('my-cli', 'My CLI');

Examples

See existing adapters:

  • src/adapters/claude-code.js - Full-featured with session resume
  • src/adapters/gemini-cli.js - Config file management
  • src/adapters/codex-cli.js - Simple spawn pattern

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.