Skip to content
OwnlyPlans

CLAUDE.md

Project rules for your AI tool. Put it in the empty project folder before step 1.

Part of Link Shortener with Click Stats (Python, nothing to install) by Admin

Download Open the item

Link shortener with click stats

Rules

  • One file: shortener.py (tests in test_shortener.py). Python 3.10+.
  • Standard library only: http.server, sqlite3, secrets, json, html, urllib.parse. No pip packages.
  • Only http and https targets. Never redirect to javascript:, data: or file: URLs.
  • Short codes come from secrets, never random. Aliases: 3-32 of A-Z a-z 0-9 - _, reserved words blocked.
  • Privacy: store only the referrer's host name and a device type, never IP addresses or full referrer URLs.
  • Escape every value you put into HTML with html.escape; build links in the browser with DOM methods, not innerHTML.
  • Bind to 127.0.0.1 by default. To put it online, run it behind a reverse proxy with HTTPS and set SHORTENER_TOKEN.

Commands

  • python shortener.py serve on http://127.0.0.1:8000 (--port, --host, --db)
  • python -m unittest run the tests
Source, 14 lines
# Link shortener with click stats

## Rules
- One file: `shortener.py` (tests in `test_shortener.py`). Python 3.10+.
- Standard library only: http.server, sqlite3, secrets, json, html, urllib.parse. No pip packages.
- Only http and https targets. Never redirect to javascript:, data: or file: URLs.
- Short codes come from `secrets`, never `random`. Aliases: 3-32 of A-Z a-z 0-9 - _, reserved words blocked.
- Privacy: store only the referrer's host name and a device type, never IP addresses or full referrer URLs.
- Escape every value you put into HTML with `html.escape`; build links in the browser with DOM methods, not innerHTML.
- Bind to 127.0.0.1 by default. To put it online, run it behind a reverse proxy with HTTPS and set SHORTENER_TOKEN.

## Commands
- `python shortener.py`  serve on http://127.0.0.1:8000 (`--port`, `--host`, `--db`)
- `python -m unittest`  run the tests

Your AI tool
Starter prompt

		

Download the plan