Trying Out OpenCode's Skills

OpenCode allows you to use skills similar to those available in Claude.
I haven’t used AI agent skills much before, but I decided to try them out as they seem convenient for automation.

Detailed information about OpenCode’s skills can be found on the official website:
Agent Skills

Skill Storage Locations

OpenCode searches for skill definitions under either the “Home Directory” or “Project Directory”.

Project Directory

Project Settings: .opencode/skills/<name>/SKILL.md
Project Claude Compatibility: .claude/skills/<name>/SKILL.md
Project Agent Compatibility: .agents/skills/<name>/SKILL.md

Home Directory

Global Settings: ~/.config/opencode/skills/<name>/SKILL.md
Global Agent Compatibility: ~/.agents/skills/<name>/SKILL.md
Global Claude Compatibility: ~/.claude/skills/<name>/SKILL.md

It seems that project-specific skills are stored in the project directory, while universal, project-agnostic skills are stored in the home directory.

Since I also use Codex regularly, I decided to save skills in .agents/skills/<name>/SKILL.md which Codex uses.

How to Write Skills

While you can write skills yourself, it’s easier to have OpenCode generate them for you.

Additionally, although skills can be described in natural language, a Yaml frontmatter is required at the beginning of the file.
The following items are mandatory in the Yaml frontmatter:

  • name
  • description

Here’s an example of the beginning of the “security-check” skill defined for this blog’s Rails application, which audits for information leaks before git commits:

---
name: security-check
description: Audit for information leaks in the entire repository before git commit. Check for hardcoded public IPs, domains, API keys, names, and fallback values for environment variables.
---

When instructed to audit for information leaks in the repository, or before executing `git commit`, use this skill.

## Verification Method

**Use pattern matching searches like grep or ripgrep only as an auxiliary tool.** The final judgment should be made by directly opening each file. Automatic searches may miss values in comments, embedded templates, or implicit default values, so **all files must be directly opened, referenced, and verified** as a principle.
(Continued...)

Once written, restarting OpenCode loads the skill.

Nevertheless, having the AI write these is better as it produces more polished results.

Language for Writing

Whether it’s SKILL.md or AGENTS.md, I think it’s acceptable to write in English or Japanese. I write in Japanese because it’s easier for me to modify or add rules.

Usage Method

Enter

/skills

to display a list of existing skills. Select one and then describe the details of what you want to execute. Alternatively, issue natural language commands, or let the AI autonomously use the skill when the appropriate timing arrives.
For example, the security check mentioned earlier can be configured in AGENTS.md as follows:

## Pre-commit Security Check

- Always execute a repository-wide information scan according to the procedures in `.agents/skills/security_check/SKILL.md` **before** executing `git commit`.
- If **CRITICAL** or **HIGH** issues are found, **halt the commit**, report the findings to the user, and await instructions.
- If only **MEDIUM** or lower issues are found, report them but allow the user to decide whether to continue the commit.
- If no issues are found, proceed with the commit normally.

This way, the security check is automatically performed when git commit is executed.
It’s convenient to store frequently executed tasks or complex instructions as skills, making life easier for yourself and ensuring rule consistency in multi-person projects.

© 2025 Hiroe Tech Notes. All rights reserved.

Comments

No comments yet.