agentleFS
SentryKnown publishergetsentry/publish/AGENTS.md

publish

AGENTS.md16 starsChanged 57 days agoApache-2.0View on GitHub

This document provides guidelines for AI coding agents working in this repository. This is the Sentry Publish Repository - a GitHub Actions-based approval system for publishing releases across multiple Sentry projects using Craft. It's a pure JavaScript (Node.js 24.0.0) project using CommonJS modules. Use CommonJS exports: Include context about what went wrong and potential fixes: Validate inputs early with descriptive error messages: Always throw for unexpected values: Before reading files:

  • Reads credentials
  • Installs packages
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 33,398 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

The file

We split this AGENTS.md into the rules it gives an agent

6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use kebab-case for all files: details-from-context.js, update-issue.js

    line 73
  2. Very specific:

    Test files go in __tests__/ subdirectory with same name as source file

    line 74
  3. Very specific:

    Run pnpm prettier before committing

    line 124
  4. Distinctive:

    Always throw for unexpected values:

    line 151
  5. Very specific:

    No need to import describe, test, expect in test files (they're global)

    line 187
  6. Very specific:

    All code is owned by @getsentry/releng (Release Engineering team).

    line 275

≈ “Common” is an estimate: at least 1 in 5 of the 43,423 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md - Coding Agent Guidelines

This document provides guidelines for AI coding agents working in this repository.

Project Overview

This is the Sentry Publish Repository - a GitHub Actions-based approval system for publishing releases across multiple Sentry projects using Craft. It's a pure JavaScript (Node.js 24.0.0) project using CommonJS modules.

Build/Lint/Test Commands

Package Manager

  • pnpm 12.8.1 (pinned in package.json) - Do NOT use yarn or npm
  • Node.js version management via Volta (pinned in package.json)

Commands

# Install dependencies
pnpm install --frozen-lockfile

# Run all tests
pnpm test

# Run tests in watch mode
pnpm test:watch

# Run a single test file
pnpm test src/modules/__tests__/update-issue.js

# Run tests matching a pattern
pnpm test -t "pattern"

# Lint code
pnpm lint

# Format code with Prettier
pnpm prettier

Running Single Tests

# By file path
pnpm test src/modules/__tests__/update-issue.js

# By test name pattern (matches describe/test names)
pnpm test -t "transformIssueBody"

# Combine file and pattern
pnpm test src/modules/__tests__/update-issue.js -t "specific test name"

Project Structure

src/
├── libs/                    # Shared utilities
│   └── __tests__/
├── modules/                 # Core business logic (reusable)
│   └── __tests__/
└── publish/                 # GitHub Actions entry points
  • libs/: Shared helper functions
  • modules/: Core business logic, designed to be reusable
  • publish/: Entry points called by GitHub Actions workflows

Code Style Guidelines

File Naming

  • Use kebab-case for all files: details-from-context.js, update-issue.js
  • Test files go in __tests__/ subdirectory with same name as source file

Variable/Function Naming

  • camelCase for variables and functions: detailsFromContext, publishRepo
  • UPPER_SNAKE_CASE for constants/regex patterns: TARGETS_SECTION_PARSER_REGEX

Module System

  • CommonJS for all source files (require/module.exports)
  • ES Modules for test files (import/export)

Import Ordering

  1. Node.js built-ins (fs, path)
  2. External packages (@actions/github, @actions/core)
  3. Local modules (relative paths)
// Example - source file
const fs = require("fs");
const github = require("@actions/github");
const core = require("@actions/core");
const { detailsFromContext } = require("../modules/details-from-context");
// Example - test file
import { vi, describe, test, expect } from "vitest";
import fs from "fs";
const { updateIssue } = require("../update-issue.js");

Exports

Use CommonJS exports:

// Named exports (preferred for multiple exports)
module.exports = { functionA, functionB };

// Single default export
module.exports = functionName;

Formatting

  • Prettier with default settings
  • Double quotes for strings
  • Semicolons required
  • Run pnpm prettier before committing

Error Handling

Throw Descriptive Errors

Include context about what went wrong and potential fixes:

throw new Error(
  'No "GITHUB_TOKEN" environment variable found. ' +
    "Please ensure the workflow is configured correctly"
);

Use Guard Clauses

Validate inputs early with descriptive error messages:

if (!context || !context.payload || !context.payload.issue) {
  throw new Error("Issue context is not defined");
}

Handle Unknown Cases in Switch Statements

Always throw for unexpected values:

switch (status) {
  case "failure":
    return {
      /* ... */
    };
  case "cancelled":
    return {
      /* ... */
    };
  case "success":
    return {
      /* ... */
    };
  default:
    throw new Error(`Unknown status: '${status}'`);
}

Check File Existence

Before reading files:

if (!fs.existsSync(CRAFT_STATE_FILE_PATH)) {
  return;
}

Testing Guidelines

Framework

  • Vitest v4.0.0 with globals enabled
  • No need to import describe, test, expect in test files (they're global)
  • Mocks are auto-cleared between tests

Test File Structure

import { vi, describe, test, expect } from "vitest";

// Mock external dependencies
vi.mock("@actions/github");
vi.mock("@actions/core");

// Import module under test AFTER mocks
const { myFunction } = require("../my-module.js");

describe("myFunction", () => {
  test("does something", () => {
    expect(myFunction()).toBe(expected);
  });
});

Mocking Patterns

// Mock a module
vi.mock("@actions/github");

// Mock with implementation
vi.mock("fs", () => ({
  existsSync: vi.fn(),
  readFileSync: vi.fn(),
}));

// Inline snapshots for complex output
expect(result).toMatchInlineSnapshot(`"expected output"`);

Key Dependencies

  • @actions/core - GitHub Actions toolkit (inputs, outputs, logging)
  • @actions/github - GitHub API client for Actions
  • @sentry/node - Sentry error reporting

Common Patterns

Async/Await with Parallel Execution

await Promise.all([operation1(), operation2()]);

Destructuring

const { repo, owner, issueNumber } = context;

Spread Operator for Object Merging

const fullContext = { ...publishRepo, additionalProp: value };

Template Literals

const message = `Release ${version} published successfully`;

Regular Expressions with Named Groups

const PARSER_REGEX = /(?<name>\w+): (?<value>.+)/;
const match = text.match(PARSER_REGEX);
const { name, value } = match.groups;

GitHub Actions Context

This codebase interacts heavily with GitHub Actions. Entry points in src/publish/ are called by workflows and use:

  • @actions/core for inputs/outputs
  • @actions/github for GitHub API interactions
  • Issue-based workflows triggered by labels and comments

Code Owners

All code is owned by @getsentry/releng (Release Engineering team).

<!-- This section is maintained by the coding agent via lore (https://github.com/BYK/loreai) -->

Long-term Knowledge

For long-term knowledge entries managed by lore (gotchas, patterns, decisions, architecture), see .lore.md in the project root.

<!-- End lore-managed section -->

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.