afero

afero is a skill for Claude Code from spf13/go-skills. It costs 131 tokens per session (2,387 once invoked), scanned A, original, MIT.

A Go skill for making file-handling code easier to test with spf13/afero, a library that lets code use replaceable filesystems. It explains in-memory files, read-only layers, and how these differ from real disks.

In plain words
What is it for?
Use it when Go code reads, writes, creates, renames, or walks files, or when you need tests or a dry-run mode for those operations.
Why use it?
Code that calls the operating system's files directly usually needs a real disk during tests. Replacing that filesystem lets tests run in memory and helps avoid changing real files.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the afero plugin — 1 skill shipped together

Good fit Use it when Go code reads, writes, creates, renames, or walks files, or when you need tests or a dry-run mode for those operations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/spf13/go-skills/afero
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add spf13/go-skills --skill afero
Clone the repo
git clone --depth 1 https://github.com/spf13/go-skills

Made for: Claude Code.

Or install afero, the plugin that ships this one along with the rest of its 1 skill.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for afero

README.md
[![agentmods](https://agentmods.dev/badge/skills/spf13/go-skills/afero/github.svg)](https://agentmods.dev/skills/spf13/go-skills/afero)
Your own site
<a href="https://agentmods.dev/skills/spf13/go-skills/afero"><img src="https://agentmods.dev/badge/skills/spf13/go-skills/afero/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for afero

Your own site · 80×15
<a href="https://agentmods.dev/skills/spf13/go-skills/afero"><img src="https://agentmods.dev/badge/skills/spf13/go-skills/afero.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 131 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,387 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00131 $0.02387
Opus 5.5 $0.00052 $0.00955
Sonnet 5.5 $0.00026 $0.00477
Haiku 4.5 $0.00013 $0.00239

Measured 17d ago against content hash e4efc725338b, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

afero scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 17d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

afero/SKILL.md · 146 lines

How it starts

The opening of the file, as written. The whole thing — 146 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Testable Filesystem Code: afero

Business logic that calls os directly can only be tested against a real disk. Inject the filesystem instead, so tests run in memory and production runs on the OS. github.com/spf13/afero is the interface for code that writes; io/fs is the interface for code that only reads.

Every behavior below was verified against afero v1.15.0 on Go 1.27.

When to Activate

  • Go code reads, writes, creates, renames, or walks files and needs unit tests.
  • A test writes temp files only to exercise file-handling logic.
  • The code takes an afero.Fs, or someone asks how to fake the filesystem.
  • A command needs a --dry-run that shows what would change without writing.
  • Code builds paths under a directory from names it does not control.

Choose the Interface by What the Code Does

The code… Accept Test with Production
only reads fs.FS fstest.MapFS os.DirFS(dir) or root.FS()
reads and writes afero.Fs afero.NewMemMapFs() afero.NewOsFs()
must stay inside a directory, whatever the names *os.Root os.OpenRoot(t.TempDir()) os.OpenRoot(dir)

Read-only code needs no dependency: io/fs and testing/fstest are the standard library. Reach for afero when the code writes.

The Pattern: Inject the Fs, Choose It in main

type Store struct {
    fs  afero.Fs
    dir string
}

func NewStore(fs afero.Fs, dir string) *Store {
    return &Store{fs: fs, dir: dir}
}

func (s *Store) Save(name string, data []byte) error {
    if err := s.fs.MkdirAll(s.dir, 0o755); err != nil {
        return err
    }
    return afero.WriteFile(s.fs, filepath.Join(s.dir, name), data, 0o644)
}
func TestSave(t *testing.T) {
    fs := afero.NewMemMapFs()
    s := NewStore(fs, "/data")
    if err := s.Save("a.txt", []byte("hi")); err != nil {
        t.Fatal(err)
    }
    got, err := afero.ReadFile(fs, "/data/a.txt")
    if err != nil || string(got) != "hi" {
        t.Fatalf("ReadFile = %q, %v", got, err)
    }
}

Read the full file on GitHub · 146 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 17d ago Changed · +7 lines · +1 tokens per session e4efc725338b
  2. 26d ago First seen · 139 lines · 130 tokens per session scan A e785a12ac6f2

Subscribe to this mod's changes

afero is a skill published in the GitHub repository spf13/go-skills (726 stars, last pushed 17d ago), licensed MIT. It adds 131 tokens to every session and 2,387 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-06.

Related

afero compared with skills from other repositories

afero next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
aferospf13/go-skillsSkill72617d agoMITA131Claude Code
golang-testingaffaan-m/ECCSkill315ktodayMITA37Claude Code, Kiro
timeouts-and-asynconsi/ginkgoSkill9.1ktodayMITA106Claude Code
setuponsi/ginkgoSkill9.1ktodayMITA118Claude Code
golang-testingsamber/cc-skills-golangSkill4.0ktodayMITA115Claude Code
golang-stretchr-testifysamber/cc-skills-golangSkill4.0ktodayMITA97Claude Code
overviewonsi/ginkgoSkill9.1ktodayMITA84Claude Code