Skip to content

chore: prep Claude Code integration#2

Merged
badMade merged 13 commits into
mainfrom
claude/prep-claude-integration-E4VUV
Apr 10, 2026
Merged

chore: prep Claude Code integration#2
badMade merged 13 commits into
mainfrom
claude/prep-claude-integration-E4VUV

Conversation

@badMade

@badMade badMade commented Apr 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Enhanced CLAUDE.md with detailed build/test commands, crate-by-crate repo map, code style conventions, and CI docs
  • Created .claude/settings.json with shared team tool permissions (allow cargo/git, deny destructive ops)
  • Updated .claude.json to use allowEdits permission mode
  • Added claude/** branch pattern to CI workflow so Claude Code branches get CI feedback
  • Expanded .gitignore for editor artifacts, OS files, and target/
  • Fixed all pre-existing cargo fmt and clippy warnings across the workspace (Rust 1.94 pedantic catches)

Test plan

  • cargo fmt --all --check passes
  • cargo clippy --workspace --all-targets -- -D warnings passes
  • All test failures are pre-existing (verified by running on main)
  • CI runs on this claude/** branch confirming the new trigger works

https://claude.ai/code/session_01HZSVJyyV6aweGbT8YkN6nY

- Enhance CLAUDE.md with detailed build/test/style instructions and
  full crate-level repository map
- Create .claude/settings.json with shared tool permissions (allow
  cargo/git commands, deny destructive operations)
- Update .claude.json to use allowEdits permission mode
- Add claude/** branch pattern to CI workflow triggers so Claude Code
  branches get CI feedback
- Expand .gitignore for editor artifacts, OS files, and Rust target/
- Fix all pre-existing cargo fmt and clippy pedantic warnings across
  the workspace (Rust 1.94 catches)

https://claude.ai/code/session_01HZSVJyyV6aweGbT8YkN6nY

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request focuses on repository configuration, documentation updates, and extensive code cleanup across the Rust workspace. Key changes include updating .claude.json and CLAUDE.md with detailed project structure and build instructions, adding a global permissions file for tool execution, and applying various Clippy-recommended refactorings such as using let-else and std::io::Error::other. A potential regression was identified in rust/crates/commands/src/lib.rs where a large set of slash commands was removed from the 'Tools' category, which may negatively impact help documentation and UI categorization.

I am having trouble creating individual review comments. Click here to see my feedback.

rust/crates/commands/src/lib.rs (1823-1831)

medium

The removal of this large block of slash commands from the Tools category in slash_command_category appears to be a regression. These commands (including core functionality like diff, commit, test, build, run, and format) will no longer be correctly categorized in the help system or UI. If these commands are still supported by the CLI, they should retain their categorization to ensure a consistent user experience in the help output.

The mock server returned `{}` for the count_tokens call, which failed
deserialization — silently skipping the preflight check and causing the
test to hang for ~7 minutes waiting on a response that never came.

Provide a valid `{"input_tokens":200000}` mock response so the
preflight correctly detects the oversized request and returns
ContextWindowExceeded without making the actual send_message call.

https://claude.ai/code/session_01HZSVJyyV6aweGbT8YkN6nY

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prepares the repo for Claude Code integration by adding shared Claude configuration/docs and ensuring CI runs on claude/** branches, alongside a workspace-wide formatting/clippy cleanup.

Changes:

  • Add Claude Code repo guidance (CLAUDE.md) and shared permissions/config (.claude/settings.json, .claude.json).
  • Update Rust CI workflow to include claude/** branch pushes.
  • Apply rustfmt/clippy-driven refactors and minor lint annotations across several Rust crates.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
rust/crates/tools/src/lib.rs Minor refactors/formatting in tool execution and provider fallback logic.
rust/crates/rusty-claude-cli/src/render.rs Small rendering/doc tweaks + clippy allowance and string-building changes.
rust/crates/rusty-claude-cli/src/main.rs Refactors for formatting/clippy and small ergonomics improvements.
rust/crates/runtime/src/worker_boot.rs Minor refactor around state-file emission + test formatting.
rust/crates/runtime/src/session.rs Modernize error construction + improve test assertion formatting.
rust/crates/runtime/src/session_control.rs Add #[must_use] to session handle creation.
rust/crates/runtime/src/prompt.rs Formatting-only changes in tests.
rust/crates/runtime/src/mcp_server.rs Formatting-only change in test handler closure.
rust/crates/runtime/src/lib.rs Reorder re-exports for consistency.
rust/crates/runtime/src/config.rs Formatting-only change in trusted roots parsing.
rust/crates/commands/src/lib.rs Simplify slash-command category mapping + minor string formatting refactor.
rust/crates/api/src/providers/openai_compat.rs Formatting-only refactors.
rust/crates/api/src/providers/anthropic.rs Formatting-only refactors + small control-flow simplification.
rust/crates/api/src/http_client.rs Add clippy allow for similar_names.
CLAUDE.md New/expanded guidance for Claude Code usage and repo commands/conventions.
.gitignore Ignore Rust target/ and common editor/OS artifacts.
.github/workflows/rust-ci.yml Add claude/** branch pattern to push trigger.
.claude/settings.json New shared Claude tool permission allow/deny list.
.claude.json Switch default permissions mode and set working directory to rust.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/rust-ci.yml
Comment thread CLAUDE.md Outdated
claude and others added 2 commits April 9, 2026 02:24
commands: update /session help assertion to match current spec that
includes the |delete <session-id> [--force] option.

plugins: use non-login shell (sh -c) for inline hook commands instead
of sh -lc, which sourced profile scripts that polluted stdout.  Also
tolerate BrokenPipe when writing the JSON payload to hook stdin — hooks
are not required to consume their input.

https://claude.ai/code/session_01HZSVJyyV6aweGbT8YkN6nY
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@badMade

badMade commented Apr 9, 2026

Copy link
Copy Markdown
Owner Author

@copilot, why is this unchecked in the PR descriptions? Is it implemented?

CI runs on this claude/** branch confirming the new trigger works
https://claude.ai/code/session_01HZSVJyyV6aweGbT8YkN6nY

@badMade

badMade commented Apr 9, 2026

Copy link
Copy Markdown
Owner Author

@copilot, why is this failing checks
Rust CI / cargo test --workspace (pull_request)
Rust CI / cargo test --workspace (pull_request)Failing after 1m

@badMade

badMade commented Apr 9, 2026

Copy link
Copy Markdown
Owner Author

@copilot, why is this failing?

failing checks
Rust CI / cargo test --workspace (pull_request)
Rust CI / cargo test --workspace (pull_request)Failing after 1m

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 21 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/rust-ci.yml
Comment thread rust/crates/plugins/src/hooks.rs
Comment thread rust/crates/rusty-claude-cli/src/main.rs Outdated
badMade and others added 4 commits April 9, 2026 13:11
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI commented Apr 9, 2026

Copy link
Copy Markdown

@copilot, why is this unchecked in the PR descriptions? Is it implemented?

CI runs on this claude/** branch confirming the new trigger works
...

The CI check item was unchecked because this was a claude/** branch and the workflow's paths: filter didn't include the Claude integration files (CLAUDE.md, .claude.json, etc.) — so pushes that only touched those files didn't trigger CI at all. That's fixed in d9664f9, which adds those paths to the filter.

@copilot, why is this failing checks
Rust CI / cargo test --workspace (pull_request)
Rust CI / cargo test --work...

The 3 failing tests were pre-existing (stale test expectations, not caused by the clippy/fmt changes in this PR). Fixed in d9664f9:

  • multi_word_prompt_still_uses_shorthand_prompt_mode: expected value updated from stale "$help overview" to the actual "help me debug"
  • repl_help_includes_shared_commands_and_exit: assertion updated to include the |delete option added to the session command
  • managed_sessions_default_to_jsonl_and_resolve_legacy_json: test now uses sessions_dir() to get the fingerprinted sessions path instead of the non-fingerprinted .claw/sessions/ path

All 156 unit tests now pass.

Copilot AI commented Apr 9, 2026

Copy link
Copy Markdown

@copilot, why is this unchecked in the PR descriptions? Is it implemented?

CI runs on this claude/** branch confirming the new trigger works
...

The checkbox was unchecked because it was aspirational — CI hadn't triggered on the claude/** branch yet at the time of the original commit. That is now resolved: the workflow paths: filter was expanded in d9664f9 to include CLAUDE.md, .claude.json, .claude/**, and .gitignore, so pushes to claude/** branches will trigger CI regardless of which files change.

@copilot, why is this failing checks
Rust CI / cargo test --workspace (pull_request)
Rust CI / cargo test --work...

The 3 failures were all pre-existing bugs in rusty-claude-cli tests (present before this PR):

  1. multi_word_prompt_still_uses_shorthand_prompt_mode — expected the stale placeholder "$help overview" instead of the actual parsed value "help me debug".
  2. repl_help_includes_shared_commands_and_exit — asserted the old /session spec without the |delete variant that had since been added.
  3. managed_sessions_default_to_jsonl_and_resolve_legacy_json — created the legacy .json file at a hardcoded .claw/sessions/ path, bypassing the workspace-fingerprinted subdirectory that sessions_dir() actually uses.

All three are fixed in commit d9664f9. cargo test -p rusty-claude-cli now shows 156 passed, 0 failed.

Same fixes as plugins/hooks.rs — use sh -c instead of sh -lc so login
profile scripts don't pollute hook stdout, and ignore BrokenPipe when
writing the JSON payload to hook stdin since hooks may exit before
consuming input.

https://claude.ai/code/session_01HZSVJyyV6aweGbT8YkN6nY
Use sh -c instead of sh -lc for both plugins and runtime hook runners.
Login shell initialization scripts (e.g. nvm) pollute stdout, which
corrupts hook output capture and causes test failures in CI.

Also tolerate BrokenPipe when writing JSON payload to hook stdin in
runtime hooks, since hooks may exit before consuming input.

https://claude.ai/code/session_01HZSVJyyV6aweGbT8YkN6nY
@badMade

badMade commented Apr 10, 2026

Copy link
Copy Markdown
Owner Author

@claude make this fix

The job is failing because --compact mode still prints non-compact UI output (spinner/progress + tool-call “frames” with ANSI cursor sequences) to stdout, so the tests that assert stdout contains only the final assistant text fail.

From the failing assertions in rust/crates/rusty-claude-cli/tests/compact_output.rs (ref c9f3651):

compact_flag_streaming_text_only_emits_final_message_text expects stdout to be exactly:
Code
Mock streaming says hello from the parity harness.\n
but it currently includes spinner + cursor save/restore + “Done” lines.
compact_flag_prints_only_final_assistant_text_without_tool_call_details expects:
Code
read_file roundtrip complete: alpha parity line
but stdout includes a rendered tool panel/frame and ANSI sequences.
Fix (what to change)

  1. In --compact mode, suppress all UI/progress rendering
    Ensure the spinner/progress renderer is either:

not created at all, or
writes to stderr (not stdout), or
is disabled when --compact is set.
Concretely: wherever you render the “Thinking…” spinner and the final “Done” status line, gate it:

Rust
if !args.compact {
ui.show_spinner(...); // or ui.render_thinking(...)
}
and similarly for any final status banner.

  1. In --compact mode, do not print tool-call details
    Any code that prints tool call IDs, tool_use JSON envelopes, or “Reading …” frames must be skipped (or redirected to stderr) when compact is enabled:

Rust
if !args.compact {
ui.render_tool_call(...);
}
3) Guarantee the final assistant text is the only stdout content in compact mode
In compact mode:

write only the final assistant text to stdout
include exactly one newline for streaming-text completion (as the test asserts)
avoid ANSI entirely on stdout
A common robust pattern:

All interactive / TUI-ish output → stderr
Machine/pipe-friendly output (--compact) → stdout only
So implement:

Rust
if args.compact {
// stdout: only final assistant text (+ newline when appropriate)
println!("{final_text}");
} else {
// normal pretty output
ui.render_message(...);
}
4) Important detail: ANSI cursor sequences are still present even with NO_COLOR=1
Your tests set NO_COLOR=1, but the failing output contains cursor save/restore (\x1b7...\x1b8) and cursor movement/clear codes. That means your output suppression must cover all ANSI control sequences, not just color. So don’t rely on NO_COLOR—explicitly disable the entire interactive renderer in compact mode (or move it to stderr).

Why this matches the failure
The captured “left” stdout in the logs includes:

spinner text (⠋ 🦀 Thinking...)
cursor/line control ANSI codes
tool panel rendering
“Done” banner
Those are exactly what the tests forbid (see assertions around Thinking, toolu_, and "tool_uses" in compact_output.rs, ref c9f365...).

Once compact mode routes/omits those UI paths and prints only the final assistant text, both tests in compact_output.rs will pass, and the cargo test --workspace job in .github/workflows/rust-ci.yml (ref c9f365...) should go green.

claude added 3 commits April 10, 2026 14:05
The compact flag was being discarded (`compact: _`) in the CliAction::Prompt
match arm and hardcoded to `false`, so --compact mode was never activated.
This caused the compact_output integration tests to fail because the full
interactive UI (spinner, tool-call details, ANSI sequences) was written to
stdout instead of only the final assistant text.

https://claude.ai/code/session_01HZSVJyyV6aweGbT8YkN6nY
… config

Root causes of CI failures:
1. All shell execution (`sh -lc`) used login shells, causing nvm init to
   pollute stdout with "nvm" text. Changed to `sh -c` in bash executor,
   sandbox launcher, plugin lifecycle, REPL runtime, and command_exists.
2. Git test helpers inherited global git config (e.g. commit.gpgsign)
   from CI runners, causing `git commit` to fail with exit 128. Added
   GIT_CONFIG_NOSYSTEM=1 and GIT_CONFIG_GLOBAL=/dev/null to isolate
   test repos from system/user configuration.

https://claude.ai/code/session_01HZSVJyyV6aweGbT8YkN6nY
… mock

Three fixes for CI test failures:

1. Skip read_piped_stdin() when a CLI prompt is provided, so that stdin
   remains available for interactive permission approval prompts. Previously
   read_piped_stdin consumed all of stdin (including the "y" answer) before
   the permission prompter could read it.

2. Handle /v1/messages/count_tokens in the mock Anthropic service with a
   stub JSON response instead of treating it as a scenario request. The
   client now makes preflight token-counting calls that were inflating the
   captured request count from 21 to 42.

3. Use workspace_fingerprint in the resume_latest integration test so
   session files are written to the correct fingerprinted subdirectory
   that SessionStore::from_cwd expects.

https://claude.ai/code/session_01HZSVJyyV6aweGbT8YkN6nY
@badMade badMade merged commit 6309a89 into main Apr 10, 2026
8 checks passed
@badMade badMade deleted the claude/prep-claude-integration-E4VUV branch April 10, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants