Getting Started
May 8, 2026 ยท View on GitHub
The Autohand Code Agent SDK for C++ spawns the Autohand CLI in JSON-RPC mode and exposes C++20 APIs for prompts, streaming events, permissions, and structured output.
Prerequisites
- Install and authenticate the Autohand CLI.
- Configure a provider in
~/.autohand/config.json. - Install CMake 3.22 or later and a C++20 compiler.
Set a custom CLI path when developing locally:
export AUTOHAND_CLI_PATH=/path/to/autohand
Installation
Use the repository as a CMake dependency:
include(FetchContent)
FetchContent_Declare(
autohand_sdk
GIT_REPOSITORY https://github.com/autohandai/code-agent-sdk-cpp.git
GIT_TAG main
)
FetchContent_MakeAvailable(autohand_sdk)
target_link_libraries(my_app PRIVATE autohand::sdk)
Your First Agent
#include <autohand/sdk.hpp>
#include <iostream>
int main() {
autohand::Agent agent(autohand::Config::from_environment().with_cwd("."));
auto result = agent.run("Summarize this repository.");
std::cout << result.text << "\n";
agent.close();
}
Streaming
autohand::AutohandSdk sdk(autohand::Config::from_environment().with_cwd("."));
sdk.start();
sdk.stream_prompt("Explain the SDK in one paragraph.", [](const autohand::SdkEvent& event) {
if (event.type == "message_update") {
std::cout << event.text_delta();
}
});
sdk.stop();
Next Steps
- Read Configuration.
- Try Event Streaming.
- Learn Permissions.
- Use SDLC Workflows for production changes.