Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Railway 9 min read Case study mediumAdept

Rewriting the CLI in Rust: Was It Worth It?

Railway rewrote its Go/Cobra CLI in Rust for v3 because the old codebase had untyped, string-defined GraphQL queries, dynamically registered flags that forced ~120 error guards, and assumptions predating multi-service projects. The Rust version uses clap derive structs with one file per command, a commands_enum! macro to generate the subcommand enum, and schema-validated GraphQL types against the new Public API. User-facing gains include tables, fuzzy-select menus via inquire, a global --json flag and automatic non-interactive mode in CI. The hardest part turned out to be cross-platform release CI and install scripts, and the rewrite broke some users' CI along the way.

Related posts

  • From Ruby to Node: Overhauling Shopify’s CLI for a Better Developer Experience

    Shopify Engineering mediumAdept

    Shopify rewrote its CLI from Ruby to TypeScript on Node to reduce system requirements, unify the Theme, App and Hydrogen workflows, and stay easy for internal teams to contribute to. Go and Rust were rejected despite their static binaries because few Shopify engineers know them. Node won over Ruby because its module system lets multiple versions of a transitive package coexist, which supports modular plugins. The new architecture rests on a shared @shopify/cli-kit package, custom ESLint rules, cross-OS CI testing, a monorepo, and a functional, MVC-like split of models, commands and services. It also uses Vitest unit tests, Cucumber E2E tests, and oclif plugins with hooks for dependency inversion.

  • Getting Started with Rust on Replit

    Replit mediumAdept

    Replit's browser IDE can host a ready-made Rust workspace, demonstrated here with a small Cargo project built in one. The project implements binary search in src/lib.rs, runs an Exercism-derived test suite with cargo test, and parses user input with Result/match. It then adds the bunt crate for colored console output and uses Replit's bundled key-value database via REPLIT_DB_URL. Along the way it explains basic Rust concepts such as borrows, Option, mut, if-as-expression and if let.

  • Our Experience Porting the YJIT Ruby Compiler to Rust

    Shopify Engineering mediumAdept

    Shopify's YJIT team ported the CRuby JIT compiler from about 11,000 lines of C99 to Rust because C's lack of modules, generics, containers and safe macros made a growing compiler hard to manage. They translated it function by function without major redesign. Pattern matching, hygienic macros, Cargo features and string handling were clear wins. The pain points were concrete: offline builds without crates.io (they fell back to invoking rustc directly), bindgen silently failing on a large internal C API, verbose manual integer casting that discourages compact data layouts, and a cyclic control-flow graph where Rc/RefCell broke down, forcing manual memory management.

  • Migrating our Messages API to Rust

    Anthropic Engineering mediumAdept

    Anthropic migrated its production Messages API from Python to Rust, using the live Python service as an oracle because tests were incomplete and the API kept changing. Rust passed about 98% of tests but initially matched only about 24% of production inputs, so they ran the model once and replayed its output to Rust, comparing every pre- and post-model checkpoint piece by piece. Privacy-safe fingerprints grouped differences and dispatched Claude agents to fix them. A partial Rust rewrite of output parsing cut CPU only 8–10% while adding cross-language overhead, so they completed the full rewrite; the Rust API now uses about 70% less CPU per request and cuts median time to first token by about 20%, with no service outage or feature freeze.

  • How to use Rust in ClickHouse: avoiding a full rewrite

    ClickHouse mediumAdept

    ClickHouse, a 1.5M-line C++ analytic database, is adopting Rust incrementally rather than rewriting. It started with Corrosion to wire Rust into CMake and a BLAKE3 hash function, then took on a client history-navigation feature, the PRQL query language, and Databricks' delta-kernel-rs for Delta Lake support. The integration problems were mostly practical: hermetic reproducible builds with vendored crates, buggy FFI wrappers caught quickly by existing CI and fuzzing, library panics that crash the server, compiling Rust with sanitizers (now easier with an MSan toolchain), duplicated cross-compilation setup, and transitive dependencies linking system OpenSSL.

The quest for software engineering knowledge.

Look:
Layout: