From CLI Invocation to SDK Integration: Best Practices for GitHub Copilot in .NET Projects
From CLI Invocation to SDK Integration: Best Practices for GitHub Copilot in .NET Projects The upgrade path from command-line invocation to official SDK integration has been quite a journey. Today,...

Source: DEV Community
From CLI Invocation to SDK Integration: Best Practices for GitHub Copilot in .NET Projects The upgrade path from command-line invocation to official SDK integration has been quite a journey. Today, I'll share the pitfalls we encountered and lessons learned in the HagiCode project. Background After the official release of the GitHub Copilot SDK in 2025, we began integrating it into our AI capability layer. Prior to this, the project primarily used GitHub Copilot capabilities by directly calling the Copilot CLI command-line tool. However, this approach presented several obvious issues: Complex process management: Need to manually manage CLI process lifecycle, startup timeouts, and process cleanup—after all, processes can crash without any warning Incomplete event handling: Raw CLI invocation makes it difficult to capture fine-grained events during model inference and tool execution—like only seeing the result without witnessing the thinking process Difficult session management: Lack of e