Runs leetcode-cli in a container so you do not need Rust or Cargo on the Mac.
docker build -t leetcode-cli .The first build compiles the crate and takes several minutes. Later rebuilds are only needed if you change this Dockerfile.
bin/leetcode and bin/leetcode-clean live in this repo. They locate the
project via their own path (no hardcoded home directory). If the leetcode-cli
image is missing, bin/leetcode builds it from this Dockerfile.
Dotfiles put bin/ on $PATH when the directory exists, so you can run:
leetcode pick 1
leetcode edit 1 # writes a Python file, then opens it in Cursor
leetcode test 1
leetcode-clean # delete generated files under .leetcode/code/
leetcode-env # leetcode-env --csrf=PASTE --session=PASTEOverride the image name with LEETCODE_CLI_IMAGE (default leetcode-cli).
This directory's .leetcode/ is bind-mounted to /root/.leetcode in the
container. Cache and generated solutions are gitignored; leetcode.toml is
committed:
.leetcode/leetcode.toml— CLI config (langispython3;siteisleetcode.com;editoristrueso the container does not open vim). Leavecsrfandsessionempty..leetcode/code/— generated solution files (leetcode editopens these in Cursor).env— cookies only (gitignored). Runleetcode-envor copy.env.example.
Chrome cookie auto-read does not work inside Docker. Log in at
leetcode.com, copy csrftoken and LEETCODE_SESSION
from DevTools cookies, and put them in .env:
LEETCODE_CSRF=<csrftoken>
LEETCODE_SESSION=<LEETCODE_SESSION>
site stays in .leetcode/leetcode.toml. The wrapper passes .env into the container with docker run --env-file.