Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
git clone --depth 1 https://github.com/noveldig/mcp-xhs-publisherWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/noveldig/mcp-xhs-publisher/python_comment_guidelines)<a href="https://agentmods.dev/rules/noveldig/mcp-xhs-publisher/python_comment_guidelines"><img src="https://agentmods.dev/badge/rules/noveldig/mcp-xhs-publisher/python_comment_guidelines/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/noveldig/mcp-xhs-publisher/python_comment_guidelines"><img src="https://agentmods.dev/badge/rules/noveldig/mcp-xhs-publisher/python_comment_guidelines.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.02315 | $0.02315 |
| Opus 5.5 | $0.00926 | $0.00926 |
| Sonnet 5.5 | $0.00463 | $0.00463 |
| Haiku 4.5 | $0.00231 | $0.00231 |
Grade A, and why
python_comment_guidelines scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 192 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Python 代码注释规范
1. 引言
1.1. 注释的重要性
注释是源代码中用于解释代码功能、逻辑、目的或使用方法的说明性文本。良好的注释能够帮助开发者理解代码,减少维护成本,并促进团队成员之间的有效沟通。
1.2. 本规范的目标
本规范旨在为 Python 项目中的代码注释提供一套统一的指导原则和最佳实践,以确保注释的质量和一致性。 本规范是 Python 编码标准指南 中关于注释部分的详细阐述和补充。
2. 通用原则
2.1. 清晰性与简洁性
注释应当清晰、准确、简洁地表达其意图。避免使用含糊不清或过于冗长的描述。
2.2. 与代码同步
注释必须与它所描述的代码保持同步。当代码发生变更时,相关的注释也应立即更新。过时或错误的注释比没有注释更糟糕。
2.3. 注释语言
- 项目内部统一:除非项目有特殊约定(例如,开源项目面向国际开发者),否则建议项目内部统一注释语言。
- 中文项目:对于主要面向中文开发者的项目,可以使用中文注释,但需注意专业术语的准确性。
- 国际化项目:对于可能需要国际协作的项目,推荐使用英文注释。
2.4. 注释不是代码的替代品
注释用于解释代码,而不是替代写出清晰、自解释的代码。应首先努力编写易于理解的代码,然后通过注释来解释那些代码本身难以表达的复杂逻辑或设计决策。
2.5. 避免多余的注释
不要为显而易见的代码添加注释。例如:
# 错误的示例 - 不必要的注释
i = i + 1 # 变量 i 自增 1
3. 注释类型
3.1. 块注释 (Block Comments)
- 用途:用于解释紧随其后的一个或多个代码段。通常用于解释复杂的逻辑、算法、重要的设计决策或代码节的总体功能。
- 格式:
- 以单个
#号和单个空格开始。 - 每行注释都是一个独立的
#注释。 - 可以有多行。
- 与它们描述的代码块具有相同的缩进级别。
- 以单个
- 示例:
# 计算斐波那契数列的前 n 项 # 使用迭代方法以提高效率 results = [] a, b = 0, 1 while len(results) < n: results.append(a) a, b = b, a + b
3.2. 行内注释 (Inline Comments)
- 用途:用于解释单行代码中不明显的部分,如复杂的表达式、变量的特殊用途或某个技巧。
- 格式:
- 在代码行的末尾,至少与代码隔开两个空格。
- 以单个
#号和单个空格开始。
- 注意事项:
- 谨慎使用,避免过多行内注释使代码显得杂乱。
- 不要解释显而易见的代码。
- 示例:
x = x + 1 # 补偿偏移量 MAX_RETRIES = 3 # 最大重试次数
3.3. 文档字符串 (Docstrings)
- 用途:为模块、类、函数、方法提供标准的说明文档。它们是 Python 语言的一个重要特性,可以被
help()函数和各种文档生成工具(如 Sphinx)提取。 - 格式:
- 使用三引号
"""Docstring goes here."""(推荐) 或\'\'\'Docstring goes here.\'\'\'。 - 文档字符串应在模块、类、函数或方法定义的下一行开始。
- 使用三引号
- 遵循 PEP 257 (Docstring Conventions) 规范:
- 单行 Docstring:对于简单的函数/方法,可以使用单行文档字符串。结束的三引号应在同一行。
def square(n): """Return the square of a number.""" return n * n - 多行 Docstring:
- 第一行是摘要行 (summary line),简明扼要地概括对象的功能。摘要行应以大写字母开头,以句号结尾。
- 摘要行之后是一个空行。
- 接着是更详细的解释,可以包括参数说明、返回值说明、可能引发的异常等。
- 结束的三引号应单独另起一行。
- 推荐格式 (Numpy/Google 风格):
def my_function(param1, param2): """一行总结函数的功能。 更详细的描述可以放在这里,解释函数的行为、 目的和任何重要的上下文。 Args: param1 (int): 第一个参数的描述。 param2 (str): 第二个参数的描述。 Returns: bool: 返回值的描述。 True 表示成功, False 表示失败。 Raises: AttributeError: 如果参数类型不正确。 ValueError: 如果参数值无效。 """ if not isinstance(param1, int): raise AttributeError("param1 必须是整数。") if not param2: raise ValueError("param2 不能为空字符串。") # 函数逻辑 return True
- 单行 Docstring:对于简单的函数/方法,可以使用单行文档字符串。结束的三引号应在同一行。
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2mo ago First seen · 192 lines · 2,315 tokens per session scan A 1f2274008a14
python_comment_guidelines is a cursor rule published in the GitHub repository noveldig/mcp-xhs-publisher (1 stars, last pushed 1y ago), licensed MIT. It adds 2,315 tokens to every session, about $0.0093 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other cursor rules, from other repositories
python_tests
We use the unit tests to cover internal behavior that can work without the web / backend counterpart. We aim for 95%+ unit test coverage of our Python code in lib/streamlit.
python-llm-ml-workflow-cursorrules-prompt-file
Cursor rules for Python LLM & ML development with workflow integration.
python
Python best practices and patterns for modern software development with Flask and SQLite.
python-containerization-cursorrules-prompt-file
Cursor rules for Python development with containerization integration.
python-django-general
General coding guidance for Python and Django projects, including naming, formatting, modular apps, built-in tools, and maintainable structure. Python is a programming language, and Django is a Python web framework.
python-general-coding-standards
A set of general standards for Python projects, including type hints, input checking, code style, security, web requests, background work, and tests. It also covers FastAPI-specific tasks such as CORS and authentication.