1.7 KiB
1.7 KiB
AGENTS.md
Purpose
This repository hosts a small self-hosted scratch service (pastebin-like) written in Go.
Key product constraints:
- All routes are unauthenticated by design.
- One upload creates one scratch.
- For multiple files, users must upload a single archive file.
- Scratch data is stored gzip-compressed on disk transparently.
Project layout
cmd/pastebin: service entrypointinternal/config: config loading and validationinternal/http: HTTP handlers and middlewareinternal/storage: filesystem storage and metadata indexinternal/cleanup: expiration cleanup workerweb/templates,web/static: UI assets
API routes
POST /api/scratchGET /api/scratch/{id}GET /s/{id}GET /raw/{id}
Build and test
Use make help as the source of truth for available build/test targets and descriptions.
Coding conventions
- Keep changes minimal and focused.
- Backward compatibility is not a concern unless explicitly requested.
- Preserve unauthenticated behavior unless explicitly requested.
- Keep limits/operator controls configurable via config.
- Maintain write-route protections (allowlist and rate limiting).
- Keep storage behavior transparent for clients (compression is internal).
- Add or update tests for behavior changes.
Cobra CLI conventions
- Keep
cmd/pastebin/main.gofocused onmain()and root command wiring. - Put each Cobra subcommand in its own file (for example
cmd/pastebin/server.go). - Start the service through the explicit subcommand (
scratchbox server), not from the root command directly. - Validate command arguments with Cobra arg validators (for example
cobra.NoArgs) where applicable.