<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Marquis Nobles</title>
    <description>The latest articles on Forem by Marquis Nobles (@greatnessinabox).</description>
    <link>https://forem.com/greatnessinabox</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3718332%2Fb5b9ed83-ffe7-46e0-8d61-c12a3a56149e.jpeg</url>
      <title>Forem: Marquis Nobles</title>
      <link>https://forem.com/greatnessinabox</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/greatnessinabox"/>
    <language>en</language>
    <item>
      <title>drift: Real-Time Code Health + AI-Powered Refactoring with GitHub Copilot CLI</title>
      <dc:creator>Marquis Nobles</dc:creator>
      <pubDate>Thu, 12 Feb 2026 15:12:55 +0000</pubDate>
      <link>https://forem.com/greatnessinabox/drift-real-time-code-health-ai-powered-refactoring-with-github-copilot-cli-5a1e</link>
      <guid>https://forem.com/greatnessinabox/drift-real-time-code-health-ai-powered-refactoring-with-github-copilot-cli-5a1e</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/github-2026-01-21"&gt;GitHub Copilot CLI Challenge&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;Ever had a 200-line function that "just worked" so you never refactored it? 🙈&lt;/p&gt;

&lt;p&gt;The problem: Code quality tools tell you &lt;strong&gt;what's wrong&lt;/strong&gt; (high complexity, tech debt, stale dependencies), but they don't help you &lt;strong&gt;fix it&lt;/strong&gt;. You're left staring at a dashboard of red metrics with no clear path forward.&lt;/p&gt;

&lt;p&gt;I built &lt;strong&gt;drift&lt;/strong&gt; - a real-time codebase health monitor that doesn't just identify problems, it helps you fix them with AI. Think Datadog for your codebase, but with a GitHub Copilot-powered "fix it for me" button.&lt;/p&gt;

&lt;h3&gt;
  
  
  Three Ways drift Uses GitHub Copilot CLI
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Interactive Fixing&lt;/strong&gt; — &lt;code&gt;drift fix&lt;/code&gt; calls the Copilot CLI to get AI refactoring advice&lt;br&gt;
&lt;strong&gt;2. Custom Agent&lt;/strong&gt; — &lt;code&gt;@drift&lt;/code&gt; commands extend Copilot with code health expertise&lt;br&gt;
&lt;strong&gt;3. CI Automation&lt;/strong&gt; — GitHub Actions use Copilot CLI to generate friendly PR comments&lt;/p&gt;

&lt;p&gt;drift watches your &lt;strong&gt;Go/TypeScript/Python/Rust/Java/Ruby/PHP/C#&lt;/strong&gt; projects in real-time and provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cyclomatic complexity analysis with sparkline trends&lt;/li&gt;
&lt;li&gt;Dependency freshness tracking against package registries&lt;/li&gt;
&lt;li&gt;Architecture boundary violation detection&lt;/li&gt;
&lt;li&gt;Dead code identification&lt;/li&gt;
&lt;li&gt;AI-powered diagnostics and refactoring suggestions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a developer who's inherited way too much tech debt, I wanted a tool that goes beyond "you have problems" to "here's how to solve them." GitHub Copilot CLI made this possible - AI can now be your pair programming partner for refactoring, not just new code.&lt;/p&gt;


&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Quick Start
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;copilot-cli          &lt;span class="c"&gt;# GitHub Copilot CLI&lt;/span&gt;
go &lt;span class="nb"&gt;install &lt;/span&gt;github.com/greatnessinabox/drift@latest
&lt;span class="nb"&gt;cd &lt;/span&gt;your-project
drift
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Live TUI Dashboard
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fozj0bt6qn6m7n3fxntl7.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fozj0bt6qn6m7n3fxntl7.gif" alt="drift dashboard demo" width="1600" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The dashboard shows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Health Score&lt;/strong&gt; (0-100) with gradient color bar and sparkline trends from git history&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Complexity Panel&lt;/strong&gt; — Functions sorted by cyclomatic complexity with severity indicators&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependencies Panel&lt;/strong&gt; — Package freshness with days since latest release&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Boundaries Panel&lt;/strong&gt; — Architecture violations (e.g., &lt;code&gt;api → db&lt;/code&gt; forbidden imports)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Activity Panel&lt;/strong&gt; — Real-time file change notifications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Navigate with &lt;strong&gt;Tab&lt;/strong&gt;, refresh with &lt;strong&gt;r&lt;/strong&gt;, press &lt;strong&gt;d&lt;/strong&gt; for AI diagnosis, &lt;strong&gt;q&lt;/strong&gt; to quit.&lt;/p&gt;
&lt;h3&gt;
  
  
  Interactive AI-Powered Fixing
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;drift fix

🔍 Analyzing codebase... &lt;span class="o"&gt;(&lt;/span&gt;Score: 78/100&lt;span class="o"&gt;)&lt;/span&gt;

Found 3 issue&lt;span class="o"&gt;(&lt;/span&gt;s&lt;span class="o"&gt;)&lt;/span&gt; to fix:
1. &lt;span class="o"&gt;[&lt;/span&gt;🔴 HIGH] model.Update&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="k"&gt;in &lt;/span&gt;app.go:126 &lt;span class="o"&gt;(&lt;/span&gt;complexity: 25&lt;span class="o"&gt;)&lt;/span&gt;
2. &lt;span class="o"&gt;[&lt;/span&gt;🟡 MEDIUM] validateInput&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="k"&gt;in &lt;/span&gt;handler.go:89 &lt;span class="o"&gt;(&lt;/span&gt;complexity: 18&lt;span class="o"&gt;)&lt;/span&gt;
3. &lt;span class="o"&gt;[&lt;/span&gt;🟢 LOW] parseConfig&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="k"&gt;in &lt;/span&gt;config.go:34 &lt;span class="o"&gt;(&lt;/span&gt;complexity: 12&lt;span class="o"&gt;)&lt;/span&gt;

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
&lt;span class="o"&gt;[&lt;/span&gt;1/3] model.Update&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="k"&gt;in &lt;/span&gt;app.go:126 &lt;span class="o"&gt;(&lt;/span&gt;complexity: 25&lt;span class="o"&gt;)&lt;/span&gt;
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🤖 Asking GitHub Copilot &lt;span class="k"&gt;for &lt;/span&gt;suggestions...

&lt;span class="o"&gt;[&lt;/span&gt;Copilot provides context-aware refactoring advice]

Apply this suggestion? &lt;span class="o"&gt;[&lt;/span&gt;y/N/s&lt;span class="o"&gt;(&lt;/span&gt;kip rest&lt;span class="o"&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;What's happening:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;drift analyzes your codebase and identifies complex functions&lt;/li&gt;
&lt;li&gt;For each issue, it extracts the function source code&lt;/li&gt;
&lt;li&gt;It builds a language-aware prompt: "Refactor this function to reduce complexity from 25 to &amp;lt;10..." with source code and metrics&lt;/li&gt;
&lt;li&gt;It calls &lt;code&gt;copilot -p &amp;lt;prompt&amp;gt; -s --add-dir &amp;lt;project&amp;gt;&lt;/code&gt; to get AI suggestions in non-interactive mode&lt;/li&gt;
&lt;li&gt;You review and choose: accept, reject, or skip remaining suggestions&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;
  
  
  Real-World Test: Running drift fix on an OSS Codebase
&lt;/h4&gt;

&lt;p&gt;I ran &lt;code&gt;drift fix&lt;/code&gt; against &lt;a href="https://github.com/greatnessinabox/sinew" rel="noopener noreferrer"&gt;sinew&lt;/a&gt;, my open-source React pattern library (150 files, 998 functions):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;drift report
Health Score: 55/100

Top complexity offenders:
  🔴 Playground&lt;span class="o"&gt;()&lt;/span&gt;  playground.tsx:128  &lt;span class="o"&gt;(&lt;/span&gt;complexity: 48&lt;span class="o"&gt;)&lt;/span&gt;
  🔴 add&lt;span class="o"&gt;()&lt;/span&gt;         patterns.ts:89     &lt;span class="o"&gt;(&lt;/span&gt;complexity: 47&lt;span class="o"&gt;)&lt;/span&gt;
  🔴 PatternPage&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;.tsx:45        &lt;span class="o"&gt;(&lt;/span&gt;complexity: 45&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;drift fix &lt;span class="nt"&gt;--limit&lt;/span&gt; 1

🔍 Analyzing codebase... &lt;span class="o"&gt;(&lt;/span&gt;Score: 55.0/100&lt;span class="o"&gt;)&lt;/span&gt;

Found 1 issue&lt;span class="o"&gt;(&lt;/span&gt;s&lt;span class="o"&gt;)&lt;/span&gt; to fix:
1. &lt;span class="o"&gt;[&lt;/span&gt;🔴 HIGH] Playground&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="k"&gt;in &lt;/span&gt;playground.tsx:128 &lt;span class="o"&gt;(&lt;/span&gt;complexity: 48&lt;span class="o"&gt;)&lt;/span&gt;

🤖 Asking GitHub Copilot &lt;span class="k"&gt;for &lt;/span&gt;suggestions...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copilot CLI read the actual source file via &lt;code&gt;--add-dir&lt;/code&gt;, analyzed the 48-complexity &lt;code&gt;Playground()&lt;/code&gt; component, and returned a full refactoring plan:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Extracted custom hooks&lt;/strong&gt; (&lt;code&gt;useKeyboardNavigation&lt;/code&gt;, &lt;code&gt;useStepHighlighting&lt;/code&gt;) to reduce nested effects&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Map-based dispatch&lt;/strong&gt; for keyboard handlers instead of if-else chains&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Component extraction&lt;/strong&gt; (&lt;code&gt;OutputTabButton&lt;/code&gt;, &lt;code&gt;StepsBadge&lt;/code&gt;, &lt;code&gt;LogsBadge&lt;/code&gt;) to eliminate JSX conditionals&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Helper functions&lt;/strong&gt; (&lt;code&gt;getVisualizationComponent&lt;/code&gt;, &lt;code&gt;handleExecutionSuccess&lt;/code&gt;) to flatten switch statements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Estimated complexity reduction: &lt;strong&gt;48 → ~12&lt;/strong&gt; — well below the threshold. This wasn't generic advice — Copilot understood the React component structure, the custom hooks pattern, and TypeScript types.&lt;/p&gt;

&lt;h3&gt;
  
  
  Custom Agent with @drift Commands
&lt;/h3&gt;

&lt;p&gt;Created a custom GitHub Copilot agent with 10+ specialized commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Analyze specific directory&lt;/span&gt;
copilot &lt;span class="nt"&gt;--agent&lt;/span&gt; drift-dev &lt;span class="s2"&gt;"@drift analyze internal/analyzer/"&lt;/span&gt;

&lt;span class="c"&gt;# Get refactoring suggestions for a function&lt;/span&gt;
copilot &lt;span class="nt"&gt;--agent&lt;/span&gt; drift-dev &lt;span class="s2"&gt;"@drift suggest-refactor complexFunction()"&lt;/span&gt;

&lt;span class="c"&gt;# Explain what cyclomatic complexity means&lt;/span&gt;
copilot &lt;span class="nt"&gt;--agent&lt;/span&gt; drift-dev &lt;span class="s2"&gt;"@drift explain complexity"&lt;/span&gt;

&lt;span class="c"&gt;# Compare health between commits&lt;/span&gt;
copilot &lt;span class="nt"&gt;--agent&lt;/span&gt; drift-dev &lt;span class="s2"&gt;"@drift compare HEAD~5 HEAD"&lt;/span&gt;

&lt;span class="c"&gt;# Get language-specific best practices&lt;/span&gt;
copilot &lt;span class="nt"&gt;--agent&lt;/span&gt; drift-dev &lt;span class="s2"&gt;"@drift best-practices go"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent understands drift's architecture and metrics, acting as a domain expert that can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Analyze code patterns and suggest improvements&lt;/li&gt;
&lt;li&gt;Explain why certain metrics matter&lt;/li&gt;
&lt;li&gt;Compare health across git history&lt;/li&gt;
&lt;li&gt;Debug analyzer issues&lt;/li&gt;
&lt;li&gt;Recommend best practices&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  GitHub Action for PR Health Checks
&lt;/h3&gt;

&lt;p&gt;Created &lt;code&gt;.github/workflows/drift-health.yml&lt;/code&gt; that runs on every PR:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Run drift analysis&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;go install github.com/greatnessinabox/drift@latest&lt;/span&gt;
    &lt;span class="s"&gt;drift check --fail-under 70 &amp;gt; report.txt&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Generate Copilot-powered summary&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;copilot -p "Create a friendly PR comment summarizing this drift report: $(cat report.txt)" -s --no-auto-update&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of just failing CI with a red X, the Action uses Copilot to generate helpful comments:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Hey! 👋 I noticed a few complex functions in this PR. The &lt;code&gt;handleRequest()&lt;/code&gt; function (complexity: 23) might benefit from extracting the validation logic into a separate helper. The health score is currently 68/100, just under the 70 threshold. Want me to suggest a refactoring? 🤖"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Much friendlier than "COMPLEXITY CHECK FAILED ❌"&lt;/p&gt;

&lt;h3&gt;
  
  
  Try It Yourself
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Repo:&lt;/strong&gt; &lt;a href="https://github.com/greatnessinabox/drift" rel="noopener noreferrer"&gt;https://github.com/greatnessinabox/drift&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docs:&lt;/strong&gt; &lt;a href="https://github.com/greatnessinabox/drift#readme" rel="noopener noreferrer"&gt;README.md&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom Agent:&lt;/strong&gt; &lt;a href="https://github.com/greatnessinabox/drift/blob/main/.github/agents/drift-dev.agent.md" rel="noopener noreferrer"&gt;drift-dev.agent.md&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Action:&lt;/strong&gt; &lt;a href="https://github.com/greatnessinabox/drift/blob/main/.github/workflows/drift-health.yml" rel="noopener noreferrer"&gt;drift-health.yml&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  My Experience with GitHub Copilot CLI
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Journey: Three Integration Patterns
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Phase 1: Discovery (Custom Agents)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I started by reading the Copilot CLI docs and discovered custom agents. Creating &lt;code&gt;.github/agents/drift-dev.agent.md&lt;/code&gt; felt like defining an API - I specified commands, described drift's domain, and explained the codebase structure.&lt;/p&gt;

&lt;p&gt;The magic happened when I tried it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;copilot &lt;span class="nt"&gt;--agent&lt;/span&gt; drift-dev &lt;span class="s2"&gt;"explain complexity"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Suddenly, Copilot &lt;strong&gt;understood drift's domain&lt;/strong&gt;. It could explain cyclomatic complexity in the context of the project, suggest which files to refactor first based on drift's metrics, and even compare health trends across commits.&lt;/p&gt;

&lt;p&gt;This wasn't generic AI - it was an expert assistant that "knew" drift.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key learning:&lt;/strong&gt; Custom agents transform Copilot from a general coding assistant into a specialized consultant for your project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 2: Deeper Integration (Interactive Fixing)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next challenge: Could I build &lt;code&gt;drift fix&lt;/code&gt; to call Copilot programmatically from within the tool itself?&lt;/p&gt;

&lt;p&gt;Turns out, &lt;strong&gt;yes&lt;/strong&gt; - via subprocess:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;prompt&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;buildCopilotPrompt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;issue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// includes source code + metrics&lt;/span&gt;
&lt;span class="n"&gt;cmd&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;exec&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Command&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"copilot"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"-p"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"-s"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                    &lt;span class="c"&gt;// silent: output only the AI response&lt;/span&gt;
    &lt;span class="s"&gt;"--add-dir"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cfg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c"&gt;// grant file access to the project&lt;/span&gt;
    &lt;span class="s"&gt;"--no-auto-update"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CombinedOutput&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key insight: &lt;strong&gt;Prompt engineering matters&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Initial prompts gave generic advice:&lt;br&gt;
❌ "Refactor this function to reduce complexity"&lt;br&gt;
→ Generic response about extracting functions&lt;/p&gt;

&lt;p&gt;Better prompts with context gave 10x better suggestions:&lt;br&gt;
✅ "Refactor this Go function to reduce complexity from 25 to &amp;lt;10:&lt;/p&gt;

&lt;p&gt;File: app.go:126-180&lt;br&gt;
Function: model.Update()&lt;br&gt;
Current issues: Nested if/else, multiple return paths&lt;/p&gt;

&lt;p&gt;[function source code here]&lt;/p&gt;

&lt;p&gt;Suggest extract-method refactoring with descriptive function names that follow Go conventions."&lt;/p&gt;

&lt;p&gt;→ Specific, actionable refactoring with code examples&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The more context you give Copilot (source code, file paths, specific metrics, goals), the better it performs&lt;/li&gt;
&lt;li&gt;Structured prompts with clear sections (context, code, goal) work best&lt;/li&gt;
&lt;li&gt;Copilot excels at extract-method and extract-variable refactorings&lt;/li&gt;
&lt;li&gt;Including current complexity metrics helps it understand the severity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Phase 3: CI Automation (GitHub Actions)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The final piece: Using Copilot in CI pipelines to make automation friendlier.&lt;/p&gt;

&lt;p&gt;I created a GitHub Action that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Runs drift analysis on every PR&lt;/li&gt;
&lt;li&gt;Captures the output (health score, issues, trends)&lt;/li&gt;
&lt;li&gt;Calls &lt;code&gt;copilot -p&lt;/code&gt; to transform the technical report into a friendly comment&lt;/li&gt;
&lt;li&gt;Posts it to the PR&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The transformation is incredible. Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Drift Health Check FAILED
Score: 68/100 (threshold: 70)
High complexity functions: 3
Stale dependencies: 2
Boundary violations: 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PRs now get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hey! 👋 The health score is at 68/100, just under the 70 threshold.

I found a few opportunities to improve:

🔴 High Complexity:
- model.Update() in app.go:126 (complexity: 25)
  Consider extracting the validation logic into a helper function

🟡 Stale Dependencies:
- axios is 180 days old (latest: 1.7.0)
  Updating would include security fixes

Want me to suggest refactorings for these? Just comment "@drift fix" 🤖
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Impact:&lt;/strong&gt; Teams actually read and act on these comments vs ignoring red CI failures.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-World Development Impact
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Velocity:&lt;/strong&gt; Building drift took ~3 days with Copilot CLI vs my estimated week solo. The custom agent answered architecture questions instantly (no context-switching to docs), and Copilot CLI's non-interactive mode (&lt;code&gt;copilot -p&lt;/code&gt;) for implementation saved hours of Stack Overflow diving.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quality:&lt;/strong&gt; Copilot's refactoring suggestions were genuinely good - not toy examples. I accepted ~70% without modification. The extract-method patterns it suggested were often cleaner than my usual approach, following proper Go/TypeScript conventions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learning:&lt;/strong&gt; I discovered integration patterns I didn't know existed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Custom agents can have domain-specific command vocabularies&lt;/li&gt;
&lt;li&gt;Subprocess calls enable programmatic AI usage in any language&lt;/li&gt;
&lt;li&gt;Copilot in CI makes automation feel less robotic and more helpful&lt;/li&gt;
&lt;li&gt;Prompt engineering is more important than I thought&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Surprises (Good and Bad)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What Exceeded Expectations:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Copilot's refactoring suggestions were &lt;strong&gt;production-ready&lt;/strong&gt;, not academic examples&lt;/li&gt;
&lt;li&gt;The custom agent "remembered" drift's architecture across conversations - it understood the relationship between analyzers, the health scorer, and the TUI&lt;/li&gt;
&lt;li&gt;Prompt engineering was intuitive once I started including code context and specific goals&lt;/li&gt;
&lt;li&gt;Error messages from Copilot CLI were helpful when I messed up prompts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Challenges:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Error handling:&lt;/strong&gt; When Copilot CLI isn't installed, drift needed graceful fallbacks (now shows helpful install message)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt length limits:&lt;/strong&gt; Very long functions (500+ lines) had to be truncated or extracted into focused prompts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interactive terminal UX:&lt;/strong&gt; Capturing Copilot's output and presenting it nicely in a TUI required careful stream handling&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate limiting:&lt;/strong&gt; Rapid-fire suggestions could hit API limits (added throttling and caching)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advice for Builders Using Copilot CLI
&lt;/h3&gt;

&lt;p&gt;If you're building Copilot CLI integrations, here's what I learned:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Start with a custom agent&lt;/strong&gt; — It's the easiest way to extend Copilot with domain knowledge. Just create &lt;code&gt;.github/agents/your-agent.agent.md&lt;/code&gt; and define commands.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Context is king&lt;/strong&gt; — The more context you provide in prompts (code, metrics, goals, constraints), the better suggestions you get. Don't just say "refactor this" - explain why, what metrics are concerning, and what good looks like.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Non-interactive mode is powerful&lt;/strong&gt; — The standalone Copilot CLI's &lt;code&gt;-p&lt;/code&gt; flag (prompt) and &lt;code&gt;-s&lt;/code&gt; flag (silent output) make programmatic integration seamless. Just call &lt;code&gt;copilot -p "&amp;lt;prompt&amp;gt;" -s&lt;/code&gt; from your tool via &lt;code&gt;exec.Command()&lt;/code&gt; (Go), &lt;code&gt;subprocess.run()&lt;/code&gt; (Python), or equivalent.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;User agency matters&lt;/strong&gt; — Let users review AI suggestions before applying them. The "accept/reject/skip" pattern in &lt;code&gt;drift fix&lt;/code&gt; respects developer judgment. Trust, but verify.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Handle missing dependencies&lt;/strong&gt; — Not everyone has Copilot CLI installed. Detect this early (&lt;code&gt;exec.LookPath("copilot")&lt;/code&gt;) and show a friendly installation guide.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Structured prompts &amp;gt; prose&lt;/strong&gt; — Format prompts with clear sections (Context, Code, Goal, Constraints). Copilot parses structure better than long paragraphs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test edge cases&lt;/strong&gt; — What if the function has no source code available? What if Copilot returns unexpected output? What if the user cancels mid-process? Handle these gracefully.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What Worked Really Well
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;three-layer integration&lt;/strong&gt; (custom agent + interactive fixing + CI automation) created a coherent AI-enhanced experience:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Development time:&lt;/strong&gt; Custom agent answers questions and explains decisions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Refactoring time:&lt;/strong&gt; &lt;code&gt;drift fix&lt;/code&gt; provides on-demand suggestions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Review time:&lt;/strong&gt; GitHub Action makes PR reviews more actionable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each layer complements the others. The custom agent teaches developers about code health concepts, &lt;code&gt;drift fix&lt;/code&gt; applies that knowledge to their code, and the GitHub Action ensures quality gates are friendly, not frustrating.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's Next for drift
&lt;/h3&gt;

&lt;p&gt;I'm excited to expand the Copilot integration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Automatic patch application:&lt;/strong&gt; Generate and apply refactoring patches directly (with approval)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-time suggestions in the TUI:&lt;/strong&gt; Show Copilot suggestions as you edit files in the live dashboard&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Team dashboards:&lt;/strong&gt; Aggregate health across repositories with Copilot-generated insights&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-AI support:&lt;/strong&gt; While built for Copilot CLI, drift also works with Claude Code, Cursor, Aider, and other AI assistants (see &lt;a href="https://github.com/greatnessinabox/drift/blob/main/.github/AI_AGENTS.md" rel="noopener noreferrer"&gt;AI_AGENTS.md&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Try It
&lt;/h3&gt;

&lt;p&gt;If you maintain a Go/TypeScript/Python/Rust/Java/Ruby/PHP/C# codebase, give drift a spin:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;copilot-cli                                       &lt;span class="c"&gt;# Copilot CLI&lt;/span&gt;
go &lt;span class="nb"&gt;install &lt;/span&gt;github.com/greatnessinabox/drift/cmd/drift@latest   &lt;span class="c"&gt;# drift&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;your-project
drift fix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'd love feedback on the Copilot integration patterns - what works, what doesn't, what would make it more useful?&lt;/p&gt;




&lt;h2&gt;
  
  
  Closing Thoughts
&lt;/h2&gt;

&lt;p&gt;GitHub Copilot CLI transformed drift from a &lt;strong&gt;monitoring tool&lt;/strong&gt; into an &lt;strong&gt;AI-powered improvement engine&lt;/strong&gt;. The three integration patterns (custom agent, interactive fixing, CI automation) demonstrate how AI can enhance every stage of development:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local iteration:&lt;/strong&gt; Custom agent as expert consultant&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Focused refactoring:&lt;/strong&gt; Interactive suggestions with approval workflow&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code review:&lt;/strong&gt; Friendly, actionable PR comments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The future of developer tools isn't just identifying problems - it's &lt;strong&gt;helping solve them with AI assistance&lt;/strong&gt;. With Copilot CLI, we can build that future today.&lt;/p&gt;

&lt;p&gt;The best part? These patterns are reusable. Any CLI tool can:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a custom agent (&lt;code&gt;.github/agents/&lt;/code&gt;) with domain-specific commands&lt;/li&gt;
&lt;li&gt;Call &lt;code&gt;copilot -p "&amp;lt;prompt&amp;gt;" -s&lt;/code&gt; programmatically for AI-powered features&lt;/li&gt;
&lt;li&gt;Use Copilot CLI in CI to make automation more human-friendly&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Thanks for reading!&lt;/strong&gt; 🚀 Questions? Find me in the comments or open an issue on the &lt;a href="https://github.com/greatnessinabox/drift" rel="noopener noreferrer"&gt;drift repo&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Repository:&lt;/strong&gt; &lt;a href="https://github.com/greatnessinabox/drift" rel="noopener noreferrer"&gt;https://github.com/greatnessinabox/drift&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Custom Agent:&lt;/strong&gt; &lt;a href="https://github.com/greatnessinabox/drift/blob/main/.github/agents/drift-dev.agent.md" rel="noopener noreferrer"&gt;drift-dev.agent.md&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Demo GIFs:&lt;/strong&gt; &lt;a href="https://github.com/greatnessinabox/drift/raw/main/demo-quick.gif" rel="noopener noreferrer"&gt;Quick&lt;/a&gt; | &lt;a href="https://github.com/greatnessinabox/drift/raw/main/demo-tui.gif" rel="noopener noreferrer"&gt;TUI&lt;/a&gt; | &lt;a href="https://github.com/greatnessinabox/drift/raw/main/demo-dashboard.gif" rel="noopener noreferrer"&gt;Dashboard&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>githubchallenge</category>
      <category>cli</category>
      <category>githubcopilot</category>
    </item>
    <item>
      <title>I’m done copy-pasting infrastructure code from old projects</title>
      <dc:creator>Marquis Nobles</dc:creator>
      <pubDate>Sun, 18 Jan 2026 19:16:26 +0000</pubDate>
      <link>https://forem.com/greatnessinabox/im-done-copy-pasting-infrastructure-code-from-old-projects-2c0o</link>
      <guid>https://forem.com/greatnessinabox/im-done-copy-pasting-infrastructure-code-from-old-projects-2c0o</guid>
      <description>&lt;p&gt;Infrastructure work is rarely interesting—but it’s always necessary.&lt;/p&gt;

&lt;p&gt;Over time I noticed I was solving the same problems again and again:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Copying configs from old projects and inheriting their mistakes&lt;/li&gt;
&lt;li&gt;Stitching together tutorials that were already drifting out of date&lt;/li&gt;
&lt;li&gt;Adding packages I didn’t really need, just to delete them later&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I built Sinew.&lt;/p&gt;

&lt;p&gt;It’s a pattern registry of infrastructure code I actually trust in production. You copy the code into your project. That’s it. No abstractions, no hidden behavior.&lt;/p&gt;

&lt;p&gt;What’s included so far (30+ patterns):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Database: pooling, Prisma edge, Drizzle&lt;/li&gt;
&lt;li&gt;Auth: OAuth, sessions, RBAC&lt;/li&gt;
&lt;li&gt;API: rate limiting, validation, error handling&lt;/li&gt;
&lt;li&gt;Caching: in-memory, Next.js cache, Redis&lt;/li&gt;
&lt;li&gt;Payments: Stripe, LemonSqueezy&lt;/li&gt;
&lt;li&gt;Email: Resend, Nodemailer, AWS SES&lt;/li&gt;
&lt;li&gt;Monitoring: Sentry, logging, OpenTelemetry&lt;/li&gt;
&lt;li&gt;Testing: Vitest, Playwright&lt;/li&gt;
&lt;li&gt;Deployment: Docker, GitHub Actions, Vercel&lt;/li&gt;
&lt;li&gt;Environment: type-safe env + secrets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Browse: &lt;a href="https://sinew.marquis.codes" rel="noopener noreferrer"&gt;https://sinew.marquis.codes&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or use the CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g sinew
sinew add database/connection-pooling
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most infrastructure code doesn’t need to be a package. It just needs to be correct, understandable, and easy to adapt. That’s the goal here.&lt;/p&gt;

&lt;p&gt;Curious what pieces you end up rewriting the most.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
