agentleFS
SentryKnown publishergetsentry/craft/AGENTS.md

craft

AGENTS.md196 starsChanged 36 days agoMITView on GitHub

This file provides guidance for AI coding assistants working with the Craft codebase. To manually test changes: Craft supports a --dry-run flag that prevents destructive operations. This is implemented via a centralized abstraction layer. Instead of checking isDryRun() manually in every function, destructive operations are wrapped with dry-run-aware proxies: ESLint rules prevent direct usage of raw APIs: If you're writing a wrapper module that needs raw access, use: When adding new code that performs destructive operations: Some operations need explicit…

  • 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.

  • In this repositoryOne other file it gives its agents.

The file

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

11 rules. About 0 are common, 2 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

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

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

    Test files are located in src/__tests__/ and follow the *.test.ts naming pattern.

    line 56
  2. Very specific:

    Run tests with pnpm test.

    line 57
  3. Very specific:

    Use vi.fn(), vi.mock(), vi.spyOn() for mocking (Vitest's mock API).

    line 58
  4. Very specific:

    Instead of checking isDryRun() manually in every function, destructive operations are wrapped with dry-run-aware proxies:

    line 77
  5. Very specific:

    Git operations: Use getGitClient() from src/utils/git.ts or createGitClient(directory) for working with specific directories

    line 79
  6. Very specific:

    GitHub API: Use getGitHubClient() from src/utils/githubApi.ts

    line 80
  7. Very specific:

    File writes: Use safeFs from src/utils/dryRun.ts

    line 81
  8. Very specific:

    Other actions: Use safeExec() or safeExecSync() from src/utils/dryRun.ts

    line 82
  9. Distinctive:

    If you're writing a wrapper module that needs raw access, use:

    line 91
  10. Distinctive:

    When adding new code that performs destructive operations:

    line 100
  11. Very specific:

    File writes: Use safeFs.writeFile(), safeFs.unlink(), etc.

    line 104

≈ “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

This file provides guidance for AI coding assistants working with the Craft codebase.

Package Management

  • Always use pnpm for package management. Never use npm or yarn.
  • Node.js version is managed by Volta (currently v22.12.0).
  • Install dependencies with pnpm install --frozen-lockfile.

Development Commands

CommandDescription
pnpm buildBuild the project (outputs to dist/craft)
pnpm testRun tests
pnpm lintRun ESLint
pnpm fixAuto-fix lint issues

To manually test changes:

pnpm build && ./dist/craft

Code Style

  • TypeScript is used throughout the codebase.
  • Prettier 3.x with single quotes and no arrow parens (configured in .prettierrc.yml).
  • ESLint 9.x with flat config (eslint.config.mjs) using typescript-eslint.
  • Unused variables prefixed with _ are allowed (e.g., _unusedParam).

Project Structure

src/
├── __mocks__/          # Test mocks
├── __tests__/          # Test files (*.test.ts)
├── artifact_providers/ # Artifact provider implementations
├── commands/           # CLI command implementations
├── schemas/            # Valibot schemas and TypeScript types for config
├── status_providers/   # Status provider implementations
├── targets/            # Release target implementations
├── types/              # Shared TypeScript types
├── utils/              # Utility functions
├── config.ts           # Configuration loading
├── index.ts            # CLI entry point
└── logger.ts           # Logging utilities
dist/
└── craft               # Single bundled executable (esbuild output)

Testing

  • Tests use Vitest.
  • Test files are located in src/__tests__/ and follow the *.test.ts naming pattern.
  • Run tests with pnpm test.
  • Use vi.fn(), vi.mock(), vi.spyOn() for mocking (Vitest's mock API).

CI/CD

  • Main branch is master.
  • CI runs tests on Node.js 20 and 22.
  • Craft releases itself using its own tooling (dogfooding).

Configuration

  • Project configuration lives in .craft.yml at the repository root.
  • The configuration schema is defined in src/schemas/.

Dry-Run Mode

Craft supports a --dry-run flag that prevents destructive operations. This is implemented via a centralized abstraction layer.

How It Works

Instead of checking isDryRun() manually in every function, destructive operations are wrapped with dry-run-aware proxies:

  • Git operations: Use getGitClient() from src/utils/git.ts or createGitClient(directory) for working with specific directories
  • GitHub API: Use getGitHubClient() from src/utils/githubApi.ts
  • File writes: Use safeFs from src/utils/dryRun.ts
  • Other actions: Use safeExec() or safeExecSync() from src/utils/dryRun.ts

ESLint Enforcement

ESLint rules prevent direct usage of raw APIs:

  • no-restricted-imports: Blocks direct simple-git imports
  • no-restricted-syntax: Blocks new Octokit() instantiation

If you're writing a wrapper module that needs raw access, use:

// eslint-disable-next-line no-restricted-imports -- This is the wrapper module
import simpleGit from 'simple-git';

Adding New Destructive Operations

When adding new code that performs destructive operations:

  1. Git: Get the git client via getGitClient() or createGitClient() - mutating methods are automatically blocked
  2. GitHub API: Get the client via getGitHubClient() - create*, update*, delete*, upload* methods are automatically blocked
  3. File writes: Use safeFs.writeFile(), safeFs.unlink(), etc. instead of raw fs methods
  4. Other: Wrap with safeExec(action, description) for custom operations

Special Cases

Some operations need explicit isDryRun() checks:

  • Commands with their own --dry-run flag (e.g., dart pub publish --dry-run in pubDev target)
  • Operations that need to return mock data in dry-run mode
  • User experience optimizations (e.g., skipping sleep timers)
<!-- 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.