cd /news/developer-tools/snake-and-commits-turn-your-github-c… · home topics developer-tools article
[ARTICLE · art-66337] src=github.com ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

Snake-and-commits: Turn your GitHub contribution graph into a real game of Snake

Developer David Liu released snake-and-commits, a Python tool that turns a GitHub contribution graph into a playable Snake game using BFS pathfinding and animated SVG. The tool, available at github.com/dahan8473/snake-and-commits, runs as a GitHub Action with zero dependencies and supports four themes. It respects prefers-reduced-motion and is MIT licensed.

read3 min views2 publishedJul 21, 2026
Snake-and-commits: Turn your GitHub contribution graph into a real game of Snake
Image: source

Your GitHub contribution graph, but it's a real game of Snake.

The snake plays an actual, winnable game. It hunts every commit cell with real pathfinding, never crosses its own body, grows one segment per cell it eats, fades from a bright head to a dim tail, and counts the commits it swallows. Pure animated SVG (CSS, no JavaScript), so it renders anywhere GitHub shows an image.

  • 🐍 Real Snake AI: BFS pathfinding, self-collision avoidance, tail-chasing when boxed in - 🍎 Eats your commits: each contribution cell is food, with a live counter - 📈 Grows as it eats: starts at 3 segments, gains one per cell, head-to-tail gradient - 🎨 Themeable:green

(default),blue

,amber

,matrix

  • 🪶 Zero dependencies: one standard-library Python file - ♿ Respects: falls back to a static graphprefers-reduced-motion

Add one workflow to your profile repo (the repo named after your username). Create .github/workflows/snake.yml

:

name: snake
on:
  schedule:
    - cron: "0 */12 * * *"   # twice a day
  workflow_dispatch:
permissions:
  contents: write
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: dahan8473/snake-and-commits@v1
        with:
          github_user: ${{ github.repository_owner }}
          output: dist/snake.svg
          theme: green
      - uses: crazy-max/ghaction-github-pages@v4
        with:
          target_branch: output
          build_dir: dist
        env:
          GITHUB_TOKEN: ${{ github.token }}

Run it once from the Actions tab, then add this to your README.md

:

![snake](https://raw.githubusercontent.com/YOUR_NAME/YOUR_NAME/output/snake.svg)

It regenerates on schedule from your live contribution data.

Generate two themes and switch with <picture>

:

<picture>
  <source media="(prefers-color-scheme: dark)"  srcset=".../output/snake-dark.svg">
  <source media="(prefers-color-scheme: light)" srcset=".../output/snake-light.svg">
  <img src=".../output/snake-dark.svg" alt="contribution snake">
</picture>
input default description
github_user
required whose graph to render (usually ${{ github.repository_owner }} )
output
dist/snake.svg
output path
theme
green
green , blue , amber , matrix
frame
false
draw a rounded window frame around the graph
counter
true
show the commits eaten: n/total counter
theme look
🟩 green
native GitHub
🟦 blue
phosphor terminal
🟧 amber
old CRT
matrix
bright-on-black
GH_TOKEN=$(gh auth token) python3 generate.py --user YOUR_NAME --output snake.svg --theme green

One file, standard library only. Any token that can read public contribution data works.

  • Pull a year of contribution levels from the GitHub GraphQL API.
  • Solve the board like a Snake game. From a corner, BFS to the nearest commit cell (sparsest first), always avoiding the body. If the best target is walled off, chase the tail until space opens. The route is collision-free, and the max length is auto-tuned to the largest snake that still clears the board.
  • Render it as a cell-state animation. Each grid square animates its own fill: bright when the head enters, fading down the body, back to background as the tail passes. Nothing moves, so segments can never overlap.

Built by David Liu. Inspired by the contribution-graph art tradition (Platane/snk and friends), rebuilt from scratch as an actual game of Snake. MIT licensed.

pls drop a star!

── more in #developer-tools 4 stories · sorted by recency
── more on @david liu 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/snake-and-commits-tu…] indexed:0 read:3min 2026-07-21 ·