---
title: "triaging-go-data-races"
description: "Groups and ranks Go data race reports from `go test -race` or `go run -race` output, then finds the shared variable and missing synchronization for each one. Use when the user has \"WARNING: DATA RACE\" output, a CI log where tests failed with \"race detected during execution of test\", asks why the race detector fails, or wants to know if a branch adds new data races."
canonical_url: "https://skilld.dev/gh/gillmacedo/racesift"
last_updated: "2026-11-12T06:01:39.000Z"
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

---
name: triaging-go-data-races
description: Groups and ranks Go data race reports from `go test -race` or `go run -race` output, then finds the shared variable and missing synchronization for each one. Use when the user has "WARNING: DATA RACE" output, a CI log where tests failed with "race detected during execution of test", asks why the race detector fails, or wants to know if a branch adds new data races.
---

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install gillmacedo/racesift/triaging-go-data-races`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/triaging-go-data-races`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/gillmacedo/racesift/triaging-go-data-races) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/triaging-go-data-races`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/triaging-go-data-races --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/triaging-go-data-races --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Triaging Go data races

The race detector prints one long report per race it sees, and the same race often repeats across tests. Group them first with the bundled tool. It only reads text and needs Go installed.

## Get the output

If the user has a log or CI output, save it to a file and use that. Otherwise run the tests, narrowed to the package in question when you know it:

    go test -race ./... 2>&1 | tee /tmp/race.log

`go test -json` output and GitHub Actions logs, with their timestamps, also work. `-race` needs cgo on some platforms. If it fails to build, say so rather than guessing.

## Run the tool

    go run "${CLAUDE_PLUGIN_ROOT}/scripts/racesift.go" review /tmp/race.log

It prints each distinct race once, ranked by how many tests hit it, with both code locations, the tests, where each goroutine started, and hints (`RS101` to `RS108`). "Lines in more than one race" lists code that shows up in several races. Start there, because one missing lock often causes several races. Add `--json` for structured output.

To check a branch, run the tests on both and compare. Races are matched by the functions involved, so line changes elsewhere don't make an old race look new:

    go run "${CLAUDE_PLUGIN_ROOT}/scripts/racesift.go" compare base.log head.log

## Check each race in the code

Hints are leads from the stack shape, not proof. For each race:

1. Read both locations. Name the variable or field they share, and say which goroutines touch it.
2. Find the missing happens-before link: a lock one side forgets, a field read before `wg.Wait`, a value captured by a closure, or a struct replaced while in use.
3. When a side has no frame from the user's code (`RS108`), use where its goroutine started and the other side to find it. Say that the location is inferred.
4. When every frame is in `_test.go` files (`RS107`), check whether the test itself is wrong before changing the code under test.

## Report

1. List races worst first: those hit by the most tests, or on hot lines. Give `file:line` for both sides and the shared variable.
2. Propose the smallest fix in the project's style: a mutex the type already has, an `atomic` type, a channel, or a copy before starting the goroutine.
3. After a fix, suggest rerunning with `go test -race -count=5` on that package. One clean run doesn't prove a race is gone.

## Don't

- Don't edit code unless the user asks.
- Don't suggest `time.Sleep`, retries, or skipping `-race` to make a race go away.
- Don't say code is race free because nothing was reported. The race detector only sees races that happen during that run.
