---
title: Reuse extensions across configurations
description: Define extensions independently, select them from Context, and reuse the same implementation across multiple Vector Configurations.
sidebar:
  label: Reuse
---

Each specific `defineX` helper creates an Extension Definition. Keep definitions in independent modules, then let each Vector Configuration select the definitions it needs.

## Keep the extension independent

Continue with the command from the Quickstart. Its name is fixed when `defineCommand()` runs, while its template is built later from the active Context.

```ts title="src/extensions/project-summary.ts"
import { defineCommand } from '@evilkiwi/vector';

export const projectSummary = defineCommand({
  name: 'project-summary',
  build: (context) => ({
    template: `Summarize the project at ${context.project.canonical}`,
  }),
});
```

The exported value has no activation-specific state. Vector supplies Context when it materializes a selected definition.

## Select it for a team configuration

Use the root `build(context)` callback for plan selection. This configuration includes the command only when OpenCode supplies a workspace identity.

```ts title="src/configurations/team.ts"
import { defineVector } from '@evilkiwi/vector';

import { projectSummary } from '../extensions/project-summary.js';

export default defineVector({
  id: 'team',
  build: (context) => ({
    commands: context.project.workspaceId === undefined ? [] : [projectSummary],
  }),
});
```

The condition changes the Extension Plan. It does not mutate the Extension Definition.

## Select it again without copying it

A local configuration can select the same definition unconditionally.

```ts title="src/configurations/local.ts"
import { defineVector } from '@evilkiwi/vector';

import { projectSummary } from '../extensions/project-summary.js';

export default defineVector({
  id: 'local',
  build: () => ({ commands: [projectSummary] }),
});
```

Each activation creates a separate Snapshot. Vector passes one Context value to the configuration callback and every selected extension callback in that activation.

## Reuse an External Skill definition

An External Skill definition also remains independent of activation-specific state. Export one Local Skill or Managed Skill definition and select it from multiple Vector Configurations.

```ts title="src/extensions/review.ts"
import { defineSkill } from '@evilkiwi/vector';

export const review = defineSkill({
  id: 'review',
  external: {
    type: 'managed',
    manager: 'skills',
    source: 'acme/team-skills',
  },
});
```

Managed definitions with the same ID, normalized source, selected skill, and ref share one user cache across plugins and projects. The default `when-missing` policy reuses a valid entry. Select the exported `review` value in each configuration's `skills` array; do not copy or flatten its external descriptor fields.

Add per-installation values with [Runtime config](/build/runtime-config), or look up every helper in [Extensions](/api/extensions).
