{"slug": "snake-and-commits-turn-your-github-contribution-graph-into-a-real-game-of-snake", "title": "Snake-and-commits: Turn your GitHub contribution graph into a real game of Snake", "summary": "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.", "body_md": "Your GitHub contribution graph, but it's a real game of Snake.\n\nThe 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.\n\n- 🐍\n**Real Snake AI**: BFS pathfinding, self-collision avoidance, tail-chasing when boxed in - 🍎\n**Eats your commits**: each contribution cell is food, with a live counter - 📈\n**Grows as it eats**: starts at 3 segments, gains one per cell, head-to-tail gradient - 🎨\n**Themeable**:`green`\n\n(default),`blue`\n\n,`amber`\n\n,`matrix`\n\n- 🪶\n**Zero dependencies**: one standard-library Python file - ♿\n**Respects**: falls back to a static graph`prefers-reduced-motion`\n\nAdd one workflow to your profile repo (the repo named after your username).\nCreate `.github/workflows/snake.yml`\n\n:\n\n```\nname: snake\non:\n  schedule:\n    - cron: \"0 */12 * * *\"   # twice a day\n  workflow_dispatch:\npermissions:\n  contents: write\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: dahan8473/snake-and-commits@v1\n        with:\n          github_user: ${{ github.repository_owner }}\n          output: dist/snake.svg\n          theme: green\n      - uses: crazy-max/ghaction-github-pages@v4\n        with:\n          target_branch: output\n          build_dir: dist\n        env:\n          GITHUB_TOKEN: ${{ github.token }}\n```\n\nRun it once from the Actions tab, then add this to your `README.md`\n\n:\n\n```\n![snake](https://raw.githubusercontent.com/YOUR_NAME/YOUR_NAME/output/snake.svg)\n```\n\nIt regenerates on schedule from your live contribution data.\n\nGenerate two themes and switch with `<picture>`\n\n:\n\n```\n<picture>\n  <source media=\"(prefers-color-scheme: dark)\"  srcset=\".../output/snake-dark.svg\">\n  <source media=\"(prefers-color-scheme: light)\" srcset=\".../output/snake-light.svg\">\n  <img src=\".../output/snake-dark.svg\" alt=\"contribution snake\">\n</picture>\n```\n\n| input | default | description |\n|---|---|---|\n`github_user` |\nrequired | whose graph to render (usually `${{ github.repository_owner }}` ) |\n`output` |\n`dist/snake.svg` |\noutput path |\n`theme` |\n`green` |\n`green` , `blue` , `amber` , `matrix` |\n`frame` |\n`false` |\ndraw a rounded window frame around the graph |\n`counter` |\n`true` |\nshow the `commits eaten: n/total` counter |\n\n| theme | look |\n|---|---|\n🟩 `green` |\nnative GitHub |\n🟦 `blue` |\nphosphor terminal |\n🟧 `amber` |\nold CRT |\n⬛ `matrix` |\nbright-on-black |\n\n```\nGH_TOKEN=$(gh auth token) python3 generate.py --user YOUR_NAME --output snake.svg --theme green\n```\n\nOne file, standard library only. Any token that can read public contribution data works.\n\n- Pull a year of contribution levels from the GitHub GraphQL API.\n- 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.\n- 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.\n\nBuilt by [David Liu](https://github.com/dahan8473). Inspired by the\ncontribution-graph art tradition ([Platane/snk](https://github.com/Platane/snk)\nand friends), rebuilt from scratch as an actual game of Snake. MIT licensed.\n\npls drop a star!", "url": "https://wpnews.pro/news/snake-and-commits-turn-your-github-contribution-graph-into-a-real-game-of-snake", "canonical_source": "https://github.com/dahan8473/snake-and-commits", "published_at": "2026-07-21 03:03:31+00:00", "updated_at": "2026-07-21 03:23:01.999973+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["David Liu", "dahan8473/snake-and-commits", "GitHub", "Platane/snk"], "alternates": {"html": "https://wpnews.pro/news/snake-and-commits-turn-your-github-contribution-graph-into-a-real-game-of-snake", "markdown": "https://wpnews.pro/news/snake-and-commits-turn-your-github-contribution-graph-into-a-real-game-of-snake.md", "text": "https://wpnews.pro/news/snake-and-commits-turn-your-github-contribution-graph-into-a-real-game-of-snake.txt", "jsonld": "https://wpnews.pro/news/snake-and-commits-turn-your-github-contribution-graph-into-a-real-game-of-snake.jsonld"}}