GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(agent): add per-agent skills filtering by IgorWarzocha · Pull Request #5987 · anomalyco/opencode

feat(agent): add per-agent skills filtering #5987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
IgorWarzocha wants to merge 1 commit into anomalyco:dev from IgorWarzocha:feature/per-agent-skills

Uh oh!

There was an error while loading. Please reload this page.

Closed

feat(agent): add per-agent skills filtering #5987

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
6e1f9db
feat(agent): add per-agent skills filtering
IgorWarzocha Dec 22, 2025
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
feat(agent): add per-agent skills filtering
Add ability to filter which skills are visible to each agent via the
'skills' field in agent configuration (opencode.json or markdown frontmatter).

Supports two modes:
- Whitelist mode: when any true values present, only matching skills shown
- Blacklist mode: when only false values, exclude matching skills

Examples:
  # Only show spreadsheets skill to excel agent
  skills:
    spreadsheets: true

  # Hide git skills from read-only agent
  skills:
    "git-*": false

Uses same wildcard pattern matching as tools filtering.
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@IgorWarzocha
IgorWarzocha committed Dec 22, 2025
commit 6e1f9db52ab1ea067ef11aecb3463b337daf7498

There are no files selected for viewing

7 changes: 7 additions & 0 deletions 7 packages/opencode/src/agent/agent.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export namespace Agent {
.optional(),
prompt: z.string().optional(),
tools: z.record(z.string(), z.boolean()),
skills: z.record(z.string(), z.boolean()).optional(),
options: z.record(z.string(), z.any()),
maxSteps: z.number().int().positive().optional(),
})
Expand Down Expand Up @@ -212,6 +213,7 @@ export namespace Agent {
model,
prompt,
tools,
skills,
description,
temperature,
top_p,
Expand All @@ -236,6 +238,11 @@ export namespace Agent {
...defaultTools,
...item.tools,
}
if (skills)
item.skills = {
...item.skills,
...skills,
}
if (description) item.description = description
if (temperature != undefined) item.temperature = temperature
if (top_p != undefined) item.topP = top_p
Expand Down
6 changes: 6 additions & 0 deletions 6 packages/opencode/src/config/config.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@ export namespace Config {
top_p: z.number().optional(),
prompt: z.string().optional(),
tools: z.record(z.string(), z.boolean()).optional(),
skills: z
.record(z.string(), z.boolean())
.optional()
.describe(
"Skills filtering: true to include, false to exclude. Supports wildcards (e.g., 'git-*': false). Default is all skills enabled.",
),
disable: z.boolean().optional(),
description: z.string().optional().describe("Description of when to use the agent"),
mode: z.enum(["subagent", "primary", "all"]).optional(),
Expand Down
2 changes: 1 addition & 1 deletion 2 packages/opencode/src/session/prompt.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ export namespace SessionPrompt {
sessionID,
system: [
...(await SystemPrompt.environment()),
...(await SystemPrompt.skills()),
...(await SystemPrompt.skills(agent.skills)),
...(await SystemPrompt.custom()),
],
messages: [
Expand Down
4 changes: 2 additions & 2 deletions 4 packages/opencode/src/session/system.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ export namespace SystemPrompt {
return Promise.all(found).then((result) => result.filter(Boolean))
}

export async function skills() {
const all = await Skill.all()
export async function skills(agentSkills?: Record<string, boolean>) {
const all = agentSkills ? await Skill.forAgent(agentSkills) : await Skill.all()
if (all.length === 0) return []

const lines = [
Expand Down
41 changes: 41 additions & 0 deletions 41 packages/opencode/src/skill/skill.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Instance } from "../project/instance"
import { NamedError } from "@opencode-ai/util/error"
import { ConfigMarkdown } from "../config/markdown"
import { Log } from "../util/log"
import { Wildcard } from "../util/wildcard"

export namespace Skill {
const log = Log.create({ service: "skill" })
Expand Down Expand Up @@ -151,4 +152,44 @@ export namespace Skill {
export async function all(): Promise<Info[]> {
return state()
}

/**
* Filter skills based on a pattern map.
* Uses the same wildcard logic as tools filtering.
*
* Behavior:
* - If patterns contain any `true` values, operates in whitelist mode:
* skills must explicitly match a `true` pattern to be included.
* - If patterns contain only `false` values, operates in blacklist mode:
* skills are included unless they match a `false` pattern.
*
* @param skills List of skills to filter
* @param patterns Record of patterns to boolean (true = include, false = exclude)
* @returns Filtered list of skills
*/
export function filter(skills: Info[], patterns: Record<string, boolean> | undefined): Info[] {
if (!patterns || Object.keys(patterns).length === 0) return skills

const hasIncludes = Object.values(patterns).some((v) => v === true)

return skills.filter((skill) => {
const match = Wildcard.all(skill.name, patterns)
if (hasIncludes) {
// Whitelist mode: must explicitly match true
return match === true
}
// Blacklist mode: include unless explicitly false
return match !== false
})
}

/**
* Get skills filtered for a specific agent.
* @param agentSkills The agent's skills filter configuration
* @returns Filtered list of skills
*/
export async function forAgent(agentSkills: Record<string, boolean> | undefined): Promise<Info[]> {
const skills = await all()
return filter(skills, agentSkills)
}
}
34 changes: 34 additions & 0 deletions 34 packages/opencode/test/agent/agent.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,37 @@ Custom primary agent`,
},
})
})

test("agent markdown frontmatter supports skills filtering", async () => {
await using tmp = await tmpdir({
init: async (dir) => {
const opencodeDir = path.join(dir, ".opencode")
await fs.mkdir(opencodeDir, { recursive: true })
const agentDir = path.join(opencodeDir, "agent")
await fs.mkdir(agentDir, { recursive: true })

await Bun.write(
path.join(agentDir, "restricted.md"),
`---
mode: subagent
skills:
"*": false
"git-*": true
---
Restricted agent with skills filter`,
)
},
})
await Instance.provide({
directory: tmp.path,
fn: async () => {
const agents = await Agent.list()
const restricted = agents.find((a) => a.name === "restricted")
expect(restricted).toBeDefined()
expect(restricted?.skills).toEqual({
"*": false,
"git-*": true,
})
},
})
})
99 changes: 99 additions & 0 deletions 99 packages/opencode/test/skill/skill.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,102 @@ description: A skill in the .claude/skills directory.
},
})
})

test("Skill.filter() with undefined returns all skills", async () => {
const skills = [
{ name: "git-commit", description: "Git commit", location: "/path" },
{ name: "git-push", description: "Git push", location: "/path" },
{ name: "code-review", description: "Code review", location: "/path" },
] as Skill.Info[]

const result = Skill.filter(skills, undefined)
expect(result).toEqual(skills)
})

test("Skill.filter() with empty object returns all skills", async () => {
const skills = [
{ name: "git-commit", description: "Git commit", location: "/path" },
{ name: "git-push", description: "Git push", location: "/path" },
] as Skill.Info[]

const result = Skill.filter(skills, {})
expect(result).toEqual(skills)
})

test("Skill.filter() excludes skills with false values (blacklist mode)", async () => {
const skills = [
{ name: "git-commit", description: "Git commit", location: "/path" },
{ name: "git-push", description: "Git push", location: "/path" },
{ name: "code-review", description: "Code review", location: "/path" },
] as Skill.Info[]

const result = Skill.filter(skills, { "git-push": false })
expect(result.length).toBe(2)
expect(result.map((s) => s.name)).toEqual(["git-commit", "code-review"])
})

test("Skill.filter() supports wildcard patterns in blacklist mode", async () => {
const skills = [
{ name: "git-commit", description: "Git commit", location: "/path" },
{ name: "git-push", description: "Git push", location: "/path" },
{ name: "code-review", description: "Code review", location: "/path" },
] as Skill.Info[]

const result = Skill.filter(skills, { "git-*": false })
expect(result.length).toBe(1)
expect(result[0].name).toBe("code-review")
})

test("Skill.filter() with true values operates in whitelist mode", async () => {
const skills = [
{ name: "git-commit", description: "Git commit", location: "/path" },
{ name: "git-push", description: "Git push", location: "/path" },
{ name: "code-review", description: "Code review", location: "/path" },
] as Skill.Info[]

// Only spreadsheets: true means ONLY show skills matching true patterns
const result = Skill.filter(skills, { "git-commit": true })
expect(result.length).toBe(1)
expect(result[0].name).toBe("git-commit")
})

test("SystemPrompt.skills() filters skills when agent pattern provided", async () => {
await using tmp = await tmpdir({
git: true,
init: async (dir) => {
const skillDir1 = path.join(dir, ".opencode", "skill", "git-commit")
await Bun.write(
path.join(skillDir1, "SKILL.md"),
`---
name: git-commit
description: Git commit helper.
---
`,
)
const skillDir2 = path.join(dir, ".opencode", "skill", "code-review")
await Bun.write(
path.join(skillDir2, "SKILL.md"),
`---
name: code-review
description: Code review helper.
---
`,
)
},
})

await Instance.provide({
directory: tmp.path,
fn: async () => {
// Without filter
const allResult = await SystemPrompt.skills()
expect(allResult[0]).toContain("git-commit")
expect(allResult[0]).toContain("code-review")

// With filter excluding git-*
const filteredResult = await SystemPrompt.skills({ "git-*": false })
expect(filteredResult[0]).not.toContain("git-commit")
expect(filteredResult[0]).toContain("code-review")
},
})
})
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.