cohere-local-dev-loop
Configure Cohere local development with mocking, testing, and hot reload. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with Cohere API v2. Trigger with phrases like "cohere dev setup", "cohere local development", "cohere dev environment", "develop with cohere", "mock cohere".
Best use case
cohere-local-dev-loop is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Configure Cohere local development with mocking, testing, and hot reload. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with Cohere API v2. Trigger with phrases like "cohere dev setup", "cohere local development", "cohere dev environment", "develop with cohere", "mock cohere".
Teams using cohere-local-dev-loop should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/cohere-local-dev-loop/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How cohere-local-dev-loop Compares
| Feature / Agent | cohere-local-dev-loop | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Configure Cohere local development with mocking, testing, and hot reload. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with Cohere API v2. Trigger with phrases like "cohere dev setup", "cohere local development", "cohere dev environment", "develop with cohere", "mock cohere".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
SKILL.md Source
# Cohere Local Dev Loop
## Overview
Set up a fast, reproducible local development workflow with Cohere API v2 mocking, vitest testing, and hot reload.
## Prerequisites
- Completed `cohere-install-auth` setup
- Node.js 18+ with npm/pnpm
- TypeScript project with `tsx` or `ts-node`
## Instructions
### Step 1: Project Structure
```
my-cohere-project/
├── src/
│ ├── cohere/
│ │ ├── client.ts # CohereClientV2 wrapper
│ │ ├── chat.ts # Chat completions
│ │ ├── embed.ts # Embedding operations
│ │ └── rerank.ts # Reranking operations
│ └── index.ts
├── tests/
│ ├── chat.test.ts
│ ├── embed.test.ts
│ └── fixtures/
│ └── responses.ts # Mock API responses
├── .env.local # Local secrets (git-ignored)
├── .env.example # Template for team
└── package.json
```
### Step 2: Package Setup
```json
{
"scripts": {
"dev": "tsx watch src/index.ts",
"test": "vitest",
"test:watch": "vitest --watch",
"test:integration": "COHERE_INTEGRATION=1 vitest --run"
},
"dependencies": {
"cohere-ai": "^7.0.0"
},
"devDependencies": {
"tsx": "^4.0.0",
"vitest": "^2.0.0",
"typescript": "^5.5.0"
}
}
```
### Step 3: Client Wrapper
```typescript
// src/cohere/client.ts
import { CohereClientV2 } from 'cohere-ai';
let instance: CohereClientV2 | null = null;
export function getCohere(): CohereClientV2 {
if (!instance) {
instance = new CohereClientV2({
token: process.env.CO_API_KEY,
});
}
return instance;
}
// Reset for testing
export function resetClient(): void {
instance = null;
}
```
### Step 4: Mock Fixtures
```typescript
// tests/fixtures/responses.ts
export const mockChatResponse = {
id: 'test-chat-id',
message: {
role: 'assistant' as const,
content: [{ type: 'text' as const, text: 'Mocked response' }],
},
finishReason: 'COMPLETE' as const,
usage: { billedUnits: { inputTokens: 10, outputTokens: 5 } },
};
export const mockEmbedResponse = {
id: 'test-embed-id',
embeddings: {
float: [[0.1, 0.2, 0.3, 0.4]], // truncated for dev
},
meta: { billedUnits: { inputTokens: 4 } },
};
export const mockRerankResponse = {
id: 'test-rerank-id',
results: [
{ index: 0, relevanceScore: 0.95 },
{ index: 2, relevanceScore: 0.72 },
],
meta: { billedUnits: { searchUnits: 1 } },
};
```
### Step 5: Test with Mocks
```typescript
// tests/chat.test.ts
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { mockChatResponse } from './fixtures/responses';
vi.mock('cohere-ai', () => ({
CohereClientV2: vi.fn().mockImplementation(() => ({
chat: vi.fn().mockResolvedValue(mockChatResponse),
chatStream: vi.fn().mockReturnValue({
[Symbol.asyncIterator]: async function* () {
yield { type: 'content-delta', delta: { message: { content: { text: 'Hi' } } } };
},
}),
embed: vi.fn().mockResolvedValue({ embeddings: { float: [[0.1, 0.2]] } }),
rerank: vi.fn().mockResolvedValue({
results: [{ index: 0, relevanceScore: 0.9 }],
}),
})),
}));
describe('Cohere Chat', () => {
it('should return a chat completion', async () => {
const { CohereClientV2 } = await import('cohere-ai');
const cohere = new CohereClientV2();
const result = await cohere.chat({
model: 'command-a-03-2025',
messages: [{ role: 'user', content: 'test' }],
});
expect(result.message?.content?.[0]?.text).toBe('Mocked response');
expect(result.finishReason).toBe('COMPLETE');
});
});
```
### Step 6: Integration Tests (Optional, Hits Real API)
```typescript
// tests/integration.test.ts
import { describe, it, expect } from 'vitest';
import { CohereClientV2 } from 'cohere-ai';
const shouldRun = process.env.COHERE_INTEGRATION === '1';
describe.skipIf(!shouldRun)('Cohere Integration', () => {
const cohere = new CohereClientV2();
it('chat endpoint responds', async () => {
const res = await cohere.chat({
model: 'command-r7b-12-2024', // cheapest model for tests
messages: [{ role: 'user', content: 'Say OK' }],
maxTokens: 5,
});
expect(res.message?.content?.[0]?.text).toBeTruthy();
}, 15_000);
it('embed endpoint responds', async () => {
const res = await cohere.embed({
model: 'embed-v4.0',
texts: ['test'],
inputType: 'search_document',
embeddingTypes: ['float'],
});
expect(res.embeddings.float[0].length).toBeGreaterThan(0);
}, 15_000);
});
```
## Environment Management
```bash
# .env.example (commit this)
CO_API_KEY=your-trial-key-here
# .env.local (git-ignored, used by tsx/vitest)
CO_API_KEY=actual-key
# .gitignore entries
.env.local
.env.*.local
```
## Output
- Working dev environment with hot reload via `tsx watch`
- Unit tests with mocked Cohere responses (no API calls)
- Optional integration tests gated by `COHERE_INTEGRATION=1`
- Mock fixtures matching real API v2 response shapes
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| `vi.mock not working` | Wrong import order | Mock before importing modules |
| `CO_API_KEY undefined` | .env not loaded | Use `dotenv/config` or tsx env support |
| Integration test timeout | Slow network | Increase timeout to 15s+ |
| Type mismatch on mock | API shape changed | Update fixtures to match SDK types |
## Resources
- [Vitest Documentation](https://vitest.dev/)
- [tsx (TypeScript Execute)](https://github.com/privatenumber/tsx)
- [Cohere TypeScript SDK](https://github.com/cohere-ai/cohere-typescript)
## Next Steps
See `cohere-sdk-patterns` for production-ready code patterns.Related Skills
workhuman-local-dev-loop
Workhuman local dev loop for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman local dev loop".
wispr-local-dev-loop
Wispr Flow local dev loop for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr local dev loop".
windsurf-local-dev-loop
Configure Windsurf local development workflow with Cascade, Previews, and terminal integration. Use when setting up a development environment, configuring Turbo mode, or establishing a fast iteration cycle with Windsurf AI. Trigger with phrases like "windsurf dev setup", "windsurf local development", "windsurf dev environment", "windsurf workflow", "develop with windsurf".
webflow-local-dev-loop
Configure a Webflow local development workflow with TypeScript, hot reload, mocked API tests, and webhook tunneling via ngrok. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with the Webflow Data API. Trigger with phrases like "webflow dev setup", "webflow local development", "webflow dev environment", "develop with webflow".
vercel-local-dev-loop
Configure Vercel local development with vercel dev, environment variables, and hot reload. Use when setting up a development environment, testing serverless functions locally, or establishing a fast iteration cycle with Vercel. Trigger with phrases like "vercel dev setup", "vercel local development", "vercel dev environment", "develop with vercel locally".
veeva-local-dev-loop
Veeva Vault local dev loop for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva local dev loop".
vastai-local-dev-loop
Configure Vast.ai local development with testing and fast iteration. Use when setting up a development environment, testing instance provisioning, or building a fast iteration cycle for GPU workloads. Trigger with phrases like "vastai dev setup", "vastai local development", "vastai dev environment", "develop with vastai".
twinmind-local-dev-loop
Set up local development workflow with TwinMind API integration. Use when building applications that integrate TwinMind transcription, testing API calls locally, or developing meeting automation tools. Trigger with phrases like "twinmind dev setup", "twinmind local development", "twinmind API testing", "build with twinmind".
together-local-dev-loop
Together AI local dev loop for inference, fine-tuning, and model deployment. Use when working with Together AI's OpenAI-compatible API. Trigger: "together local dev loop".
techsmith-local-dev-loop
TechSmith local dev loop for Snagit COM API and Camtasia automation. Use when working with TechSmith screen capture and video editing automation. Trigger: "techsmith local dev loop".
supabase-local-dev-loop
Configure Supabase local development with the CLI, Docker, and migration workflow. Use when initializing a Supabase project locally, starting the local stack, writing migrations, seeding data, or iterating on schema changes. Trigger with phrases like "supabase local dev", "supabase start", "supabase init", "supabase db reset", "supabase local setup".
stackblitz-local-dev-loop
Configure local development for WebContainer applications with hot reload and testing. Use when building browser-based IDEs, testing WebContainer file operations, or setting up development workflows for WebContainer projects. Trigger: "stackblitz dev setup", "webcontainer local", "test webcontainers locally".