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.
- craft-cliSkill
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
- Very specific: line 56
Test files are located in src/__tests__/ and follow the *.test.ts naming pattern.
- Very specific: line 57
Run tests with pnpm test.
- Very specific: line 58
Use vi.fn(), vi.mock(), vi.spyOn() for mocking (Vitest's mock API).
- Very specific: line 77
Instead of checking isDryRun() manually in every function, destructive operations are wrapped with dry-run-aware proxies:
- Very specific: line 79
Git operations: Use getGitClient() from src/utils/git.ts or createGitClient(directory) for working with specific directories
- Very specific: line 80
GitHub API: Use getGitHubClient() from src/utils/githubApi.ts
- Very specific: line 81
File writes: Use safeFs from src/utils/dryRun.ts
- Very specific: line 82
Other actions: Use safeExec() or safeExecSync() from src/utils/dryRun.ts
- Distinctive: line 91
If you're writing a wrapper module that needs raw access, use:
- Distinctive: line 100
When adding new code that performs destructive operations:
- Very specific: line 104
File writes: Use safeFs.writeFile(), safeFs.unlink(), etc.
≈ “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.
Files
AGENTS.md
This file provides guidance for AI coding assistants working with the Craft codebase.
Package Management
- Always use
pnpmfor package management. Never usenpmoryarn. - Node.js version is managed by Volta (currently v22.12.0).
- Install dependencies with
pnpm install --frozen-lockfile.
Development Commands
| Command | Description |
pnpm build | Build the project (outputs to dist/craft) |
pnpm test | Run tests |
pnpm lint | Run ESLint |
pnpm fix | Auto-fix lint issues |
To manually test changes:
pnpm build && ./dist/craftCode 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) usingtypescript-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.tsnaming 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.ymlat 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()fromsrc/utils/git.tsorcreateGitClient(directory)for working with specific directories - GitHub API: Use
getGitHubClient()fromsrc/utils/githubApi.ts - File writes: Use
safeFsfromsrc/utils/dryRun.ts - Other actions: Use
safeExec()orsafeExecSync()fromsrc/utils/dryRun.ts
ESLint Enforcement
ESLint rules prevent direct usage of raw APIs:
no-restricted-imports: Blocks directsimple-gitimportsno-restricted-syntax: Blocksnew 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:
- Git: Get the git client via
getGitClient()orcreateGitClient()- mutating methods are automatically blocked - GitHub API: Get the client via
getGitHubClient()-create*,update*,delete*,upload*methods are automatically blocked - File writes: Use
safeFs.writeFile(),safeFs.unlink(), etc. instead of rawfsmethods - Other: Wrap with
safeExec(action, description)for custom operations
Special Cases
Some operations need explicit isDryRun() checks:
- Commands with their own
--dry-runflag (e.g.,dart pub publish --dry-runin 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 -->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
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.

