Skip to content

Commit 060dafd

Browse files
authored
Merge pull request #146 from philoserf/refactor/rules-token-efficiency
refactor: optimize rules files for token efficiency
2 parents 96cb691 + bb88746 commit 060dafd

File tree

7 files changed

+45
-118
lines changed

7 files changed

+45
-118
lines changed

rules/bash.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,11 @@ paths:
44
- "bin/**"
55
---
66

7-
# Bash Rules
8-
9-
## Code Quality Standards
10-
11-
- All bash scripts must pass `shellcheck` without warnings or errors
12-
- All bash scripts must be formatted with `shfmt`
13-
- Run `shfmt --write <file>` to auto-format
14-
- Run `shellcheck <file>` to validate; fix all reported issues
15-
16-
## Script Structure
17-
18-
- Include shebang line (`#!/usr/bin/env bash` or `#!/bin/bash` for portable scripts)
19-
- Use bash idioms and conventions
7+
- Must pass `shellcheck` and `shfmt`
8+
- Run `shfmt --write <file>` to format; `shellcheck <file>` to validate
9+
- Include shebang line (`#!/usr/bin/env bash` or `#!/bin/bash`)
2010
- Quote variables to prevent word splitting: `"$var"` not `$var`
2111
- Check exit codes and handle errors explicitly
2212
- Use meaningful names for functions and variables
23-
24-
## Defensive Programming
25-
26-
- Set error handling flags where appropriate: `set -euo pipefail`
13+
- Set error handling flags: `set -euo pipefail`
2714
- Avoid bare `grep` or `sed` without explicit error handling
28-
- Don't ignore command failures silently

rules/git.md

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,15 @@ paths:
33
- "**"
44
---
55

6-
# Git & GitHub Rules
7-
8-
## Branch Strategy
9-
106
- Always work on feature branches, never directly on `main`
11-
- Create descriptive feature branch names (e.g., `feature/add-auth`, `fix/login-bug`, `docs/update-readme`)
12-
- Branch from `main` unless otherwise specified
13-
14-
## Commits
15-
7+
- Create descriptive branch names (e.g., `feature/add-auth`, `fix/login-bug`, `docs/update-readme`)
168
- Write atomic commits with clear, descriptive messages
179
- Use conventional commit format when applicable (e.g., `feat:`, `fix:`, `docs:`, `refactor:`)
1810
- Keep commits focused on a single logical change
1911
- Do not commit secrets, credentials, or environment files
20-
21-
## Push
22-
23-
- **Ask before pushing**: Always confirm with the user before running `git push`
24-
- Verify the branch name and changes are correct before pushing
25-
- Push to the feature branch, not to `main`
26-
27-
## Pull Requests
28-
29-
- **Ask before creating a PR**: Always confirm with the user before running `gh pr create`
30-
- Provide a summary of what the PR does
31-
- Reference relevant issues if applicable
32-
- Ensure all commits are pushed to the feature branch before creating a PR
33-
- Use descriptive PR titles (consistent with branch naming and commit messages)
12+
- **Always confirm with user before running `git push` or `gh pr create`**
13+
- Use `git status` and `git diff` to review changes before committing
14+
- Use `gh` CLI for GitHub operations (PRs, issues, workflows)
3415
- Verify branch is up-to-date with `main` before creating a PR
35-
36-
## General Workflow
37-
38-
- Use `git status` to review changes before committing
39-
- Use `git diff` to inspect changes in detail
40-
- Use `gh` CLI for GitHub-specific operations (PRs, issues, workflows)
41-
- Use `gh api` for GitHub API interactions when needed
42-
- Commit frequently with clear messages
43-
- Keep branch history clean; avoid unnecessary merge commits when possible
16+
- Use descriptive PR titles; reference relevant issues
17+
- Keep branch history clean; avoid unnecessary merge commits

rules/images.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
paths:
3+
- "**/*.{jpg,jpeg,png,gif,webp,bmp,tiff,heic}"
4+
---
5+
6+
- **Max 20 images per batch** — stop and confirm before continuing
7+
- **Max 50 images per session** — start new conversation before limit
8+
- Use metadata tools (exiftool) over Read when possible
9+
- Use OCR tools for text extraction
10+
- Report progress after each batch: processed, remaining, "Continue?"

rules/markdown.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,9 @@ paths:
33
- "**/*.md"
44
---
55

6-
# Markdown Rules
7-
8-
## Formatting & Linting
9-
10-
- All markdown must pass `prettier` formatting
11-
- All markdown must pass `markdownlint` validation
6+
- Must pass `prettier` and `markdownlint`
127
- Run `bunx prettier --write <file>` to format
138
- Run `bunx markdownlint-cli2 <file>` to validate
14-
15-
## Markdownlint Rules
16-
17-
- **MD041 (required)**: Every code block must have a language specified (e.g., ` ```bash `, ` ```ts `, ` ```json `)
18-
- Use `text` when no other language applies
19-
- **MD013 (exempted)**: Line length is not enforced; do not break lines artificially to satisfy line limits
20-
21-
## Code Blocks
22-
23-
- Always specify a language tag for code blocks
24-
- Use language-appropriate tags: `bash`, `sh`, `ts`, `tsx`, `js`, `json`, `yaml`, `python`, `sql`, `html`, `css`, etc.
25-
- Use `text` for generic or plain text blocks
9+
- **MD041**: Every code block must have a language tag (e.g., ` ```bash `, ` ```ts `, ` ```json `); use `text` when no other applies
10+
- **MD013**: Line length is not enforced
11+
- Always specify language tags: `bash`, `sh`, `ts`, `tsx`, `js`, `json`, `yaml`, `python`, `sql`, `html`, `css`, etc.

rules/pdf.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
paths:
3+
- "**/*.pdf"
4+
---
5+
6+
- **Max 10 PDFs per batch** — stop and confirm before continuing
7+
- **Max 30 PDFs per session** — start new conversation before limit
8+
- Use text extraction tools (pdftotext, pymupdf) over Read
9+
- Use pdf-renamer skill tools for simple renaming tasks
10+
- Use pdf skill for more involved tasks
11+
- Report progress after each batch: processed, remaining, "Continue?"

rules/python.md

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,20 @@ paths:
33
- "**/*.py"
44
---
55

6-
# Python Rules
7-
8-
## Package Management & Execution
9-
10-
- Use `uv` for all dependency and environment management
11-
- Use `uvx` to run Python tools and scripts from PyPI
12-
- For self-contained scripts, use PEP 723 inline dependencies in script headers
13-
- Never use `pip`, `pip3`, `poetry`, or `pipenv`
14-
15-
## Inline Dependencies (PEP 723)
16-
17-
Self-contained scripts must declare dependencies as PEP 723 script metadata. Example:
18-
6+
- Use `uv` exclusively (never pip/poetry/pipenv); use `uvx` for PyPI tools
7+
- Self-contained scripts must use PEP 723 inline dependencies:
198
```python
209
#!/usr/bin/env python3
2110
# /// script
2211
# requires-python = ">=3.8"
23-
# dependencies = [
24-
# "requests>=2.28",
25-
# "click>=8.0",
26-
# ]
12+
# dependencies = ["requests>=2.28", "click>=8.0"]
2713
# ///
2814

2915
import requests
3016
import click
3117
```
32-
33-
Run with: `uvx --script <file.py>`
34-
35-
## Code Style
36-
37-
- Use Black for code formatting
38-
- Use Ruff for linting
18+
- Run with: `uvx --script <file.py>`
19+
- Use Black for formatting and Ruff for linting
3920
- Use type hints for function signatures
4021
- Prefer f-strings for string formatting
4122
- Use pathlib for filesystem operations

rules/typescript.md

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,13 @@ paths:
88
- "tsconfig.json"
99
---
1010

11-
# TypeScript Rules
12-
13-
## Tooling
14-
15-
- Use `bunx` to run external tools and CLI utilities (e.g., `bunx tsx`, `bunx biome check`, `bunx esbuild`)
16-
- Use `bun run <script>` for package.json scripts defined in `scripts` section
17-
- Never use `npm` or `yarn`—use `bun install` for dependencies
18-
19-
## Runtime & Execution
20-
21-
- Target Bun as the runtime. Use Bun's native APIs where applicable (file I/O, testing, bundling)
22-
- Use `bun run` to execute scripts defined in package.json
23-
- Use Bun's native test runner with `bun test` for all test files (_.test.ts,_.spec.ts)
24-
25-
## Code Style & Linting
26-
11+
- Use `bunx` for external tools, `bun run` for scripts, `bun install` for dependencies—never npm/yarn
12+
- Target Bun as the runtime; use Bun's native APIs where applicable (file I/O, testing, bundling)
13+
- Use Bun's native test runner with `bun test` for all test files (_.test.ts, _.spec.ts)
2714
- Biome is the single source of truth for formatting and linting
2815
- Follow biome.json configuration exactly; do not suggest overrides without explicit request
29-
- Run `biome check --fix` or `biome format --write` via `bun run` script when changes are needed
16+
- Run `biome check --fix` or `biome format --write` via `bun run` when changes are needed
3017
- TypeScript strict mode is enabled; submit to its defaults unless there's a strong reason to deviate
31-
32-
## Packaging & Building
33-
3418
- Use Bun's bundler (`bun build`) for creating bundles
35-
- Use Bun's package exports feature in package.json for multi-entry publishing
3619
- Ensure all TypeScript compiles cleanly with `tsc --noEmit` if a build step exists
37-
38-
## Project Structure
39-
40-
- Respect existing directory structure (e.g., bin/, src/, tests/)
41-
- Follow the conventions established in existing files within each directory
20+
- Respect existing directory structure (e.g., bin/, src/, tests/) and conventions

0 commit comments

Comments
 (0)