Skip to content

Claude code Integration Feature and Integration Tests - #2059

Open
adamwrose wants to merge 18 commits into
danielmiessler:mainfrom
adamwrose:feat/claudecode-integration-tests
Open

Claude code Integration Feature and Integration Tests#2059
adamwrose wants to merge 18 commits into
danielmiessler:mainfrom
adamwrose:feat/claudecode-integration-tests

Conversation

@adamwrose

Copy link
Copy Markdown

What this Pull Request (PR) does

Add an integration to claude code.

  • I was introduced to your project from NetworkChuck and became facinated with the work of fabric. I currently have an github copilot and claude (Anthropic pro) subscription. I noticed that the anthropic API was charged differently and claude code could use the Subscription vs paying $5 per x many tokens. I hope this will make it to where this is useful for more users with a tighter budget. If you like this, I can make one for opencode as well.

  • prerequisites

    • install claude code from either npm or brew.
    • have an anthropic subscription.

Related issues

Please reference any open issues this PR relates to in here.
If it closes an issue, type closes #[ISSUE_NUMBER].

Screenshots

I have written a lot of tests to validate my work and done some manual testing as well.

Great Work,
Adam

@ksylvan

ksylvan commented Mar 15, 2026

Copy link
Copy Markdown
Collaborator

@adamwrose Did Claude write this? What is the problem this is solving? How would I run it and test it?

@ksylvan
ksylvan marked this pull request as draft March 15, 2026 01:29
@ksylvan ksylvan self-assigned this Mar 15, 2026
…ns` in tests

- Replace custom `contains()` with stdlib `slices.Contains` in tests
- Remove redundant `contains` helper function from test file
- Add `slices` package import to test file
@ksylvan
ksylvan force-pushed the feat/claudecode-integration-tests branch from b6e8cdc to 6ab52ea Compare March 15, 2026 23:02
@ksylvan

ksylvan commented Mar 15, 2026

Copy link
Copy Markdown
Collaborator

@adamwrose Your PR description has a piece of a conversation (with some large language model?) in it....

I have written a lot of tests to validate my work and done some manual testing as well.

Great Work,
Adam

@adamwrose

Copy link
Copy Markdown
Author

I have not forgotten about this. I have been doing research on this for the last couple of weeks. There are opensource projects that expose claude code as a service that fabric and openclaw can talk to. What do you think. Want me to clean this up where AI helped me on the test cases and commit or do you want me to document a way to use claude code with an open source API?

@ksylvan

ksylvan commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator

@adamwrose Thanks for your response. I'd love for us to be able to use claude in this way without running afoul of the Anthropic Terms of Service. As far as I understand it, those claude code proxies are a gray area.

Tell me what you're thinking, let's discuss!

Comment thread internal/plugins/ai/claudecode/claudecode.go Outdated
Comment thread internal/plugins/ai/claudecode/claudecode.go
Comment thread internal/plugins/ai/claudecode/claudecode.go Outdated
Comment thread internal/plugins/ai/claudecode/claudecode.go
Comment thread internal/plugins/ai/claudecode/claudecode.go Outdated
Comment thread internal/plugins/ai/claudecode/claudecode.go Outdated
Comment thread internal/plugins/ai/claudecode/claudecode.go
Comment thread internal/plugins/ai/claudecode/claudecode.go
Comment thread internal/cli/binary_test_helpers_test.go
Comment thread internal/cli/binary_integration_test.go
ksylvan and others added 2 commits April 9, 2026 14:55
- Use exec.CommandContext in SendStream to prevent orphaned processes
- Return error on empty prompt instead of silent no-op in Send/SendStream
- Add context.Context parameter to SendStream and ListModels
- Guard channel send with select/ctx.Done() for graceful shutdown
- Strip all ANTHROPIC_* env vars in cleanEnv, not just ANTHROPIC_API_KEY
- Log debug warnings for unsupported ChatOptions (Temperature, TopP, etc.)
- Truncate prompt in debug logs to avoid noise and sensitive data leakage
- Parse and forward token usage metadata from stream events
- Add per-test timeouts to integration tests
- Add package-level doc comment

---
- there is not a --list-models from claude code so I kept the hard-coded list.
@adamwrose

Copy link
Copy Markdown
Author

@adamwrose Did Claude write this? What is the problem this is solving? How would I run it and test it?

claude helped with the testing.

@ksylvan
ksylvan marked this pull request as ready for review April 23, 2026 07:29
@ksylvan

ksylvan commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

@adamwrose What is the status of this branch?

ksylvan and others added 6 commits April 23, 2026 00:53
@adamwrose

Copy link
Copy Markdown
Author

@adamwrose What is the status of this branch?

Sorry for such a delay. my day job issues have pulled me away but I was able to spend some time on this.
I committed the following changes:

  • Stream cancellation now shuts down the ClaudeCode subprocess cleanly, integration test timeouts now
  • use context cancellation instead of panic, and I added coverage for the cancellation path.
  • I also reran the ClaudeCode integration test and go test ./..., both passing.

@adamwrose
adamwrose requested a review from ksylvan May 9, 2026 22:33
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.

2 participants