skills / rules
Cursor rule0 starsChanged 2 months agoMITView on GitHub
Pythonic idioms and PEP8 style conventions for marslo
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 4,183 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository32 other files it gives its agents.
- .claude/CLAUDE.mdCLAUDE.md
- .cursor/rules/base-rule.mdcCursor rule
- .cursor/rules/bash-style.mdcCursor rule
- .cursor/rules/groovy-implicit-return.mdcCursor rule
- .cursor/rules/groovy-style.mdcCursor rule
- .cursor/rules/markdown-style.mdcCursor rule
- automateSkill
- autopilotSkill
- canvasSkill
- create-hookSkill
- create-ruleSkill
- create-skillSkill
- create-subagentSkill
- cursor-blameSkill
- git-messageSkill
- goalSkill
- loopSkill
- migrate-to-skillsSkill
- new-repoSkill
- onboardSkill
- originSkill
- rename-chatSkill
- review-bugbotSkill
- review-securitySkill
- reviewSkill
- sdkSkill
- shareSkill
- shellSkill
- split-to-prsSkill
- statuslineSkill
- update-cli-configSkill
- update-cursor-settingsSkill
The file
We split this python-style.mdc into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Write Pythonic Python 3 that follows PEP8.
- Very specific: line 13
Every new .py file starts with this exact preamble (shebang, encoding, module docstring, and a trailing vim modeline):
- Very specific: line 70
No space before , / ; / : (E203).
- Very specific: line 112
Use def for named behavior.
- Very specific: line 113
Never use a mutable default arg.
- Very specific: line 126
Keep try bodies narrow; use except/else/finally.
≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Pythonic idioms and PEP8 style conventions for marslo
globs: **/*.py
alwaysApply: false
---
# Python Style
Write **Pythonic** Python 3 that follows PEP8. Prefer clear, idiomatic expressions over manual loops and defensive boilerplate.
## 1. New file header
Every new `.py` file starts with this exact preamble (shebang, encoding, module docstring, and a trailing vim modeline):
```python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" docstring """
# vim:tabstop=4:softtabstop=4:shiftwidth=4:expandtab:filetype=python:
```
### Docstring quoting — single- vs multi-line
- **Single-line** — text and both `"""` on one line, space-padded:
```python
""" Return the tidy, cwd-relative display path. """
```
- **Multi-line** — opening `"""` on its own line, body on the following line(s),
closing `"""` on its own line:
```python
"""
Distil raw log text at the given level.
Cumulative: L1 clean · L2 dedup+denoise · L3 heavy.
"""
```
## 2. Indentation & line length
- **One tab = 4 spaces**, `expandtab` (never hard tabs) — `E101/W191`.
- Max line length 79 (`E501`).
## 3. Bracket spacing (marslo convention — overrides PEP8)
Pad the **inner** side of the **outermost** bracket pair (`()` / `[]`) with one space on each side. A single bracket is padded too; nested inner pairs stay tight.
```python
( xxx ) # ✅ single bracket → padded
( xxx(yyy) ) # ✅ nested → outer padded, inner tight
spam( ham[1], {eggs: 2} ) # ✅ outermost () padded, inner []/{} tight
def munge( sep: str = None ): ... # ✅ padded; keyword-arg = keeps no space
income = ( gross_wages
+ taxable_interest # ✅ break before binary operators
- ira_deduction
)
spam (1) # ❌ no space before the bracket (E211)
( xxx( yyy ) ) # ❌ inner pair must stay tight
```
> ⚠ This intentionally contradicts pycodestyle `E201/E202`. If the `pycodestyle` pre-commit hook is enabled, add `--ignore=E201,E202` (keep `E211`).
## 4. Other whitespace (PEP8)
- One space around operators & after commas; none around keyword-arg `=`.
- No space before `,` / `;` / `:` (`E203`).
## 5. Imports (PEP8)
One module per line, absolute imports, at top of file — never `from x import *`.
```python
import os # ✅
import sys
from mypkg.sibling import example
import os, sys # ❌ E401
```
## 6. Prefer idioms over manual loops
```python
# ✅ pythonic # ❌ non-Pythonic
sq = [x*x for x in range(10) if x % 3 == 0] # manual append loop
total = sum(nums); hi = max(nums) # accumulator loops
dic = dict(zip(keys, values)) # enumerate + index assign
a, b = b, a # temp-var swap
' '.join(str_list) # += with trailing space
for i, item in enumerate(seq): ... # range(len(seq)) indexing
rev = s[::-1] # reversed-build loop
b = 2 if a > 2 else 1 # if/else block for one value
count = collections.Counter(items) # manual tally dict
val = dic.get(key, default) # if key in dic ... else
```
## 7. Comparisons & truthiness (PEP8)
```python
if foo is not None: ... # ✅ not `if not foo is None` (E714)
if seq: ... # ✅ not `if len(seq)` (E712)
if greeting: ... # ✅ not `== True` / `is True`
if isinstance(obj, int): ... # ✅ not `type(obj) is type(1)` (E721)
if x not in items: ... # ✅ not `not x in items` (E713)
1 <= b <= a < 10 # ✅ chained comparison
```
## 8. Functions & definitions
- Use `def` for named behavior; don't bind a `lambda` to a name (`E731`).
- Never use a **mutable default arg**; default to `None` and build inside.
- One statement per line — no `if x: a(); b()` or trailing `;` (`E701/E702/E703`).
```python
def f(x): return 2*x # ✅ not f = lambda x: 2*x
def foo(x=None): # ✅ mutable default guard
if x is None:
x = []
x.append(1)
```
## 9. Errors, resources & docstrings
- Keep `try` bodies narrow; use `except/else/finally`; catch specific exceptions.
- Manage resources with `with`; use triple-quoted docstrings for public APIs.
```python
try:
value = collection[key] # ✅ only the risky call
except KeyError:
return key_not_found(key)
else:
return handle_value(value)
with open('foo.txt', 'w') as f: # ✅ context manager
f.write('hello!')
```
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

