Skip to content

fix(init): respect --minimal flag for agent rule files#26051

Merged
Jarred-Sumner merged 1 commit into
mainfrom
claude/fix-init-minimal-agent-rules
Jan 14, 2026
Merged

fix(init): respect --minimal flag for agent rule files#26051
Jarred-Sumner merged 1 commit into
mainfrom
claude/fix-init-minimal-agent-rules

Conversation

@robobun

@robobun robobun commented Jan 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes bun init --minimal creating Cursor rules files and CLAUDE.md when it shouldn't
  • Adds regression test to verify --minimal only creates package.json and tsconfig.json

Test plan

  • Verify test fails with system bun (unfixed): USE_SYSTEM_BUN=1 bun test test/cli/init/init.test.ts -t "bun init --minimal"
  • Verify test passes with debug build: bun bd test test/cli/init/init.test.ts -t "bun init --minimal"
  • All existing init tests pass: bun bd test test/cli/init/init.test.ts

Fixes #26050

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The init command now skips creating agent (cursor) rule files when --minimal is set; a test was added to assert bun init --minimal only writes package.json and tsconfig.json and does not create other project files.

Changes

Cohort / File(s) Summary
Init command implementation
src/cli/init_command.zig
Call to Template.createAgentRule() is made conditional on minimal == false, so agent/cursor rule creation is skipped for minimal initialization.
Init command tests
test/cli/init/init.test.ts
Adds test "bun init --minimal only creates package.json and tsconfig.json" asserting only package.json and tsconfig.json are created and files like index.ts, .gitignore, README.md, CLAUDE.md, and .cursor are not present.

Possibly related PRs

  • Add Tanstack Start to bun init #24648: Modified createAgentRule usage in src/cli/init_command.zig (signature/call sites) and is code-level related to changes in how init invokes agent rule creation.

Suggested reviewers

  • Jarred-Sumner
  • alii
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: respecting the --minimal flag by not creating agent rule files during minimal initialization.
Description check ✅ Passed The PR description provides a clear summary of the fix and includes comprehensive test verification steps, though it doesn't fully follow the provided template structure.
Linked Issues check ✅ Passed The code changes directly address issue #26050 by making Template.createAgentRule() conditional on minimal flag, ensuring --minimal only creates package.json and tsconfig.json as required.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the --minimal flag behavior: conditional agent rule creation and a regression test verifying the fix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 390237adff273aaced225073106dfe9a08f980d6 and 85f4fd6.

📒 Files selected for processing (2)
  • src/cli/init_command.zig
  • test/cli/init/init.test.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.zig

📄 CodeRabbit inference engine (CLAUDE.md)

In Zig code, be careful with allocators and use defer for cleanup

Files:

  • src/cli/init_command.zig
src/**/*.zig

📄 CodeRabbit inference engine (src/CLAUDE.md)

src/**/*.zig: Use the # prefix for private fields in Zig structs, e.g., struct { #foo: u32 };
Use Decl literals in Zig, e.g., const decl: Decl = .{ .binding = 0, .value = 0 };
Place @import statements at the bottom of the file in Zig (auto formatter will handle positioning)
Never use @import() inline inside functions in Zig; always place imports at the bottom of the file or containing struct

Files:

  • src/cli/init_command.zig
**/*.test.ts?(x)

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.test.ts?(x): Never use bun test directly - always use bun bd test to run tests with debug build changes
For single-file tests, prefer -e flag over tempDir
For multi-file tests, prefer tempDir and Bun.spawn over single-file tests
Use normalizeBunSnapshot to normalize snapshot output of tests
Never write tests that check for 'panic', 'uncaught exception', or similar strings in test output
Use tempDir from harness to create temporary directories - do not use tmpdirSync or fs.mkdtempSync
When spawning processes in tests, expect stdout before expecting exit code for more useful error messages on test failure
Do not write flaky tests - do not use setTimeout in tests; instead await the condition to be met
Verify tests fail with USE_SYSTEM_BUN=1 bun test <file> and pass with bun bd test <file> - tests are invalid if they pass with USE_SYSTEM_BUN=1
Test files must end with .test.ts or .test.tsx
Avoid shell commands like find or grep in tests - use Bun's Glob and built-in tools instead

Files:

  • test/cli/init/init.test.ts
test/**/*.test.ts?(x)

📄 CodeRabbit inference engine (CLAUDE.md)

Always use port: 0 in tests - do not hardcode ports or use custom random port number functions

Files:

  • test/cli/init/init.test.ts
test/**/*.test.{ts,js,jsx,tsx,mjs,cjs}

📄 CodeRabbit inference engine (test/CLAUDE.md)

test/**/*.test.{ts,js,jsx,tsx,mjs,cjs}: Use bun bd test <...test file> to run tests with compiled code changes. Do not use bun test as it will not include your changes.
Use bun:test for files ending in *.test.{ts,js,jsx,tsx,mjs,cjs}. For test files without .test extension in test/js/node/test/{parallel,sequential}/*.js, use bun bd <file> instead of bun bd test <file> since they expect exit code 0.
Do not set a timeout on tests. Bun already has timeouts built-in.

Files:

  • test/cli/init/init.test.ts
🧠 Learnings (14)
📚 Learning: 2026-01-05T16:32:07.551Z
Learnt from: alii
Repo: oven-sh/bun PR: 25474
File: src/bun.js/event_loop/Sigusr1Handler.zig:0-0
Timestamp: 2026-01-05T16:32:07.551Z
Learning: In Zig codebases (e.g., Bun), treat std.posix.sigaction as returning void and do not perform runtime error handling for its failure. The Zig standard library views sigaction failures as programmer errors (unreachable) because they only occur with invalid signals like SIGKILL/SIGSTOP. Apply this pattern across Zig files that call sigaction (e.g., crash_handler.zig, main.zig, filter_run.zig, process.zig) and ensure failures are not handled as recoverable errors; prefer reaching an explicit unreachable/compile-time assumption when such failures are detected.

Applied to files:

  • src/cli/init_command.zig
📚 Learning: 2025-11-24T18:36:59.706Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/bun.js/bindings/v8/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:59.706Z
Learning: Applies to src/bun.js/bindings/v8/test/v8/v8.test.ts : Add corresponding test cases to test/v8/v8.test.ts using checkSameOutput() function to compare Node.js and Bun output

Applied to files:

  • test/cli/init/init.test.ts
📚 Learning: 2026-01-05T23:04:01.518Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: test/CLAUDE.md:0-0
Timestamp: 2026-01-05T23:04:01.518Z
Learning: Applies to test/**/*.test.{ts,js,jsx,tsx,mjs,cjs} : Use `bun bd test <...test file>` to run tests with compiled code changes. Do not use `bun test` as it will not include your changes.

Applied to files:

  • test/cli/init/init.test.ts
📚 Learning: 2026-01-05T23:04:01.518Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: test/CLAUDE.md:0-0
Timestamp: 2026-01-05T23:04:01.518Z
Learning: Applies to test/**/*.test.{ts,js,jsx,tsx,mjs,cjs} : Use `bun:test` for files ending in `*.test.{ts,js,jsx,tsx,mjs,cjs}`. For test files without .test extension in test/js/node/test/{parallel,sequential}/*.js, use `bun bd <file>` instead of `bun bd test <file>` since they expect exit code 0.

Applied to files:

  • test/cli/init/init.test.ts
📚 Learning: 2025-10-19T02:44:46.354Z
Learnt from: theshadow27
Repo: oven-sh/bun PR: 23798
File: packages/bun-otel/context-propagation.test.ts:1-1
Timestamp: 2025-10-19T02:44:46.354Z
Learning: In the Bun repository, standalone packages under packages/ (e.g., bun-vscode, bun-inspector-protocol, bun-plugin-yaml, bun-plugin-svelte, bun-debug-adapter-protocol, bun-otel) co-locate their tests with package source code using *.test.ts files. This follows standard npm/monorepo patterns. The test/ directory hierarchy (test/js/bun/, test/cli/, test/js/node/) is reserved for testing Bun's core runtime APIs and built-in functionality, not standalone packages.

Applied to files:

  • test/cli/init/init.test.ts
📚 Learning: 2025-12-16T00:21:32.179Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-16T00:21:32.179Z
Learning: Applies to **/*.test.ts?(x) : Never use `bun test` directly - always use `bun bd test` to run tests with debug build changes

Applied to files:

  • test/cli/init/init.test.ts
📚 Learning: 2025-12-16T00:21:32.179Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-16T00:21:32.179Z
Learning: Applies to **/*.test.ts?(x) : Verify tests fail with `USE_SYSTEM_BUN=1 bun test <file>` and pass with `bun bd test <file>` - tests are invalid if they pass with USE_SYSTEM_BUN=1

Applied to files:

  • test/cli/init/init.test.ts
📚 Learning: 2025-11-14T16:07:01.064Z
Learnt from: RiskyMH
Repo: oven-sh/bun PR: 24719
File: docs/bundler/executables.mdx:527-560
Timestamp: 2025-11-14T16:07:01.064Z
Learning: In the Bun repository, certain bundler features like compile with code splitting (--compile --splitting) are CLI-only and not supported in the Bun.build() JavaScript API. Tests for CLI-only features use backend: "cli" flag (e.g., test/bundler/bundler_compile_splitting.test.ts). The CompileBuildConfig interface correctly restricts these with splitting?: never;. When documenting CLI-only bundler features, add a note clarifying they're not available via the programmatic API.

Applied to files:

  • test/cli/init/init.test.ts
📚 Learning: 2025-10-26T01:32:04.844Z
Learnt from: Jarred-Sumner
Repo: oven-sh/bun PR: 24082
File: test/cli/test/coverage.test.ts:60-112
Timestamp: 2025-10-26T01:32:04.844Z
Learning: In the Bun repository test files (test/cli/test/*.test.ts), when spawning Bun CLI commands with Bun.spawnSync for testing, prefer using stdio: ["inherit", "inherit", "inherit"] to inherit stdio streams rather than piping them.

Applied to files:

  • test/cli/init/init.test.ts
📚 Learning: 2025-12-16T00:21:32.179Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-16T00:21:32.179Z
Learning: Applies to **/*.test.ts?(x) : Use `normalizeBunSnapshot` to normalize snapshot output of tests

Applied to files:

  • test/cli/init/init.test.ts
📚 Learning: 2025-12-16T00:21:32.179Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-16T00:21:32.179Z
Learning: Applies to **/*.test.ts?(x) : For multi-file tests, prefer `tempDir` and `Bun.spawn` over single-file tests

Applied to files:

  • test/cli/init/init.test.ts
📚 Learning: 2026-01-05T23:04:01.518Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: test/CLAUDE.md:0-0
Timestamp: 2026-01-05T23:04:01.518Z
Learning: Organize unit tests by module in directories like `/test/js/bun/` and `/test/js/node/`.

Applied to files:

  • test/cli/init/init.test.ts
📚 Learning: 2025-11-06T00:58:23.965Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 24417
File: test/js/bun/spawn/spawn.test.ts:903-918
Timestamp: 2025-11-06T00:58:23.965Z
Learning: In Bun test files, `await using` with spawn() is appropriate for long-running processes that need guaranteed cleanup on scope exit or when explicitly testing disposal behavior. For short-lived processes that exit naturally (e.g., console.log scripts), the pattern `const proc = spawn(...); await proc.exited;` is standard and more common, as evidenced by 24 instances vs 4 `await using` instances in test/js/bun/spawn/spawn.test.ts.

Applied to files:

  • test/cli/init/init.test.ts
📚 Learning: 2026-01-05T23:04:01.518Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: test/CLAUDE.md:0-0
Timestamp: 2026-01-05T23:04:01.518Z
Learning: Applies to test/**/*.test.{ts,js,jsx,tsx,mjs,cjs} : Do not set a timeout on tests. Bun already has timeouts built-in.

Applied to files:

  • test/cli/init/init.test.ts
🧬 Code graph analysis (1)
test/cli/init/init.test.ts (1)
test/harness.ts (3)
  • tempDirWithFiles (259-266)
  • bunExe (102-105)
  • bunEnv (49-64)
🔇 Additional comments (2)
src/cli/init_command.zig (1)

794-796: LGTM! Correctly guards agent rule creation for minimal mode.

The conditional properly prevents createAgentRule() from executing when --minimal is set, fixing the reported issue where Cursor rules and CLAUDE.md were created unexpectedly.

test/cli/init/init.test.ts (1)

299-327: Well-designed regression test with proper coverage.

The test effectively validates the fix by:

  1. Setting CURSOR_TRACE_ID to simulate Cursor being installed, ensuring the agent rule code path would be triggered without the fix.
  2. Verifying both expected files exist (package.json, tsconfig.json) and unwanted files don't exist (.cursor, CLAUDE.md, etc.).

This directly tests the scenario from issue #26050.


Comment @coderabbitai help to get the list of available commands and usage tips.

`bun init --minimal` was incorrectly creating Cursor rules files
(.cursor/rules/) and CLAUDE.md even though the --minimal flag should
only create package.json and tsconfig.json.

The issue was that `Template.createAgentRule()` was called unconditionally
for blank and typescript_library templates, without checking the `minimal`
flag. Other file creations (like .gitignore and README.md) correctly
respected the minimal flag via the `steps` struct.

Fixes #26050

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@robobun robobun force-pushed the claude/fix-init-minimal-agent-rules branch from 390237a to 85f4fd6 Compare January 13, 2026 23:44
@robobun

robobun commented Jan 13, 2026

Copy link
Copy Markdown
Collaborator Author
Updated 4:32 PM PT - Jan 13th, 2026

❌ Your commit 85f4fd63 has 3 failures in Build #34713 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 26051

That installs a local version of the PR into your bun-26051 executable, so you can run:

bun-26051 --bun

@Jarred-Sumner Jarred-Sumner merged commit ab009fe into main Jan 14, 2026
53 of 55 checks passed
@Jarred-Sumner Jarred-Sumner deleted the claude/fix-init-minimal-agent-rules branch January 14, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bun init --minimal includes cursor

2 participants