Back to Systems
Portable AI Tooling8 MIN READ · MIT LICENSE

CODE-STICK — AI IN YOUR POCKET.

A portable offline AI coding agent that lives on a USB drive. Plug in, get a full terminal coding agent backed by a local LLM — on any machine, in any environment, with nothing left behind when you unplug.

5PlatformsWindows · macOS (2) · Linux (2)
0Host InstallZero residue on the target machine
4+ModelsQwen · DeepSeek · CodeGemma · Phi-3
NPMReleasedcode-stick · MIT License

The Problem

Cloud AI coding agents are blocked on airgapped machines — banks, hospitals, defense contractors, classified environments. Installing Ollama and downloading a 5 GB model on every machine you touch isn't practical either, especially on borrowed laptops, school computers, or client sites.

The gap between "I have a laptop" and "I have an AI coding agent" is too wide in restricted environments. code-stick closes it: install once on a USB, carry the agent everywhere.

How It Works

USB Drive Layout After Install
<USB>/
├── code-stick.json          ← manifest (models, versions)
├── start-windows.bat        ← double-click launcher (Windows)
├── start-mac.command        ← double-click launcher (macOS)
├── start-linux.sh           ← launcher (Linux)
├── engine/
│   ├── windows-x64/         ← ollama.exe for Windows
│   ├── darwin-arm64/        ← ollama for Apple Silicon
│   ├── darwin-x64/          ← ollama for Intel Mac
│   ├── linux-x64/           ← ollama for Linux x64
│   └── linux-arm64/         ← ollama for Raspberry Pi / ARM
├── opencode/<target>/       ← opencode binary per platform
├── data/                    ← OLLAMA_MODELS (platform-agnostic blobs)
└── config/opencode/         ← opencode.json (XDG redirect)

Layer 1: Installer CLI

A TypeScript/Node.js CLI (npx code-stick install) that auto-detects the USB drive, lets you pick a coding model, and downloads pre-built Ollama + opencode binaries for all 5 platforms onto the stick. Host machine needs nothing beyond Node 20 to run the installer.

1

Layer 2: Cross-Platform Binary Bundles

Binaries are pre-built and bundled per target: Windows x64, macOS Apple Silicon, macOS Intel, Linux x64, Linux ARM64. Platform detection at launcher time ensures the right binary runs without user intervention. Hash verification guards against corrupted downloads.

2

Layer 3: USB-Local Model Store

Ollama's model blobs are pulled directly into <USB>/data with OLLAMA_MODELS redirected to the stick. Fast-mode stages in host temp then copies to USB for slow sticks. The model never touches the host's permanent storage — auto-cleaned after install.

3

Layer 4: Zero-Residue Launcher

OS-native launchers (start-windows.bat, start-mac.command, start-linux.sh) spawn Ollama from the USB, redirect opencode's config dir to the stick, and run the agent in the foreground. On exit, only the Ollama PID they spawned is killed — by PID, never by process name. The host is left clean.

4

Technical Implementation

code-stick/src/install.ts
// Install flow — auto-detect USB, pull model, write launchers
export async function runInstall(opts: InstallOptions) {
  const target = opts.target ?? await detectUsb();      // drivelist or manual
  preflightMaxPath(target);                             // Windows 260-char guard
  preflightFormat(target);                              // FAT32 4GB blob guard

  const model  = opts.model  ?? await pickModel();      // interactive picker
  const mode   = opts.mode   ?? await pickMode(target); // Fast vs Direct

  await downloadBinaries(target, ALL_PLATFORMS);        // Ollama + opencode ×5
  await pullModel(target, model, mode);                 // blobs → USB/data
  await writeLaunchers(target, model);                  // .bat / .command / .sh
  await writeManifest(target, { model, version: PKG_VERSION });
}
code-stick/templates/start-windows.bat
@echo off
:: Launcher — spawns Ollama from USB, runs opencode, kills on exit
set STICK=%~dp0
set OLLAMA_MODELS=%STICK%data
set OLLAMA_HOST=127.0.0.1:11434
set XDG_CONFIG_HOME=%STICK%config

start /B "" "%STICK%engine\windows-x64\ollama.exe" serve
:: Wait for Ollama to be ready, then launch opencode
"%STICK%opencode\windows-x64\opencode.exe"

:: PID-targeted kill — never taskkill /IM ollama.exe
taskkill /PID %OLLAMA_PID% /F >nul 2>&1

Engineering Decisions

Fast vs Direct install modesPulling a 5 GB model blob onto a slow USB stick via Ollama takes 40+ minutes. Fast mode stages in host temp (2× model size, auto-cleaned), then copies blobs — typically 5× faster on USB 2.0 sticks.

PID-targeted shutdown, not process nametaskkill /IM ollama.exe would kill any Ollama instance on the machine. The launcher stores its Ollama PID and kills only that process — critical for developers running Ollama for other projects simultaneously.

exFAT + NTFS format enforcementFAT32 has a 4 GB file-size limit. Qwen2.5-Coder 7B blobs exceed this. The installer detects the format upfront and bails with a clear message before wasting any download time.

MAX_PATH preflight on Windowsopencode's node_modules go deep. A USB mounted at a long path overflows Windows' 260-char limit mid-install. The preflight catches this before a single byte is downloaded.

The Use Cases

"Cloud AI is simply not an option in many professional environments. A bank's dev machine is airgapped by policy. A hospital can't let code leave the network. A defense contractor's laptop has no internet. code-stick is for those environments — where you still need a capable AI coding agent but the cloud is off-limits."

Airgapped & classified environments
Borrowed laptops at client sites
Privacy-sensitive NDA codebases
Flights, trains, offline conferences
School computers with locked-down installs

Supported Models

Qwen2.5-Coder 7B⭐ Recommended
qwen2.5-coder:7bRecommended all-rounder
~4.7 GB
DeepSeek-Coder 6.7B
deepseek-coder:6.7bDebugging · 80+ languages
~3.8 GB
CodeGemma 7B
codegemma:7bFill-in-middle · completion
~5.0 GB
Phi-3 Mini
phi3:miniLow-spec hardware
~2.2 GB
Work
About
Skills
Services
Blog
Contact