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/leshchenko1979/fast-mcp-telegramWrote 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/leshchenko1979/fast-mcp-telegram/code-optimization)<a href="https://agentmods.dev/rules/leshchenko1979/fast-mcp-telegram/code-optimization"><img src="https://agentmods.dev/badge/rules/leshchenko1979/fast-mcp-telegram/code-optimization/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/leshchenko1979/fast-mcp-telegram/code-optimization"><img src="https://agentmods.dev/badge/rules/leshchenko1979/fast-mcp-telegram/code-optimization.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.00000 | $0.01404 |
| Opus 5.5 | $0.00000 | $0.00562 |
| Sonnet 5.5 | $0.00000 | $0.00281 |
| Haiku 4.5 | $0.00000 | $0.00140 |
Grade A, and why
code-optimization 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 1mo 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.
Copies of this mod
1 near-identical copy found in the catalogue:
- code-optimization — 100% identical, 0 lines differ
How it starts
The opening of the file, as written. The whole thing — 239 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Code Optimization Guidelines
🎯 Core Principles
1. DRY (Don't Repeat Yourself)
- Eliminate code duplication across files and functions
- Extract shared logic into reusable functions/classes
- Centralize constants and configuration
- Use composition over duplication
2. Single Responsibility Principle
- One function = One purpose
- Separate concerns clearly (validation, processing, I/O)
- Avoid functions that do too much
- Group related functionality logically
🔍 Identifying Problems
Red Flags to Watch For:
- Duplicate constants across multiple files
- Similar function logic in different modules
- Functions with multiple responsibilities
- Artificial function boundaries that don't add value
- Mixed abstraction levels in the same function
- Redundant parameter processing
🛠️ Optimization Strategies
1. Function Consolidation
# ❌ BAD: Two functions doing similar things
def invoke_mtproto_method(method, params, params_json=""):
# Does preprocessing + Telethon interaction
def invoke_mtproto_impl(method, params_json, allow_dangerous=False):
# Does preprocessing + calls invoke_mtproto_method
# ✅ GOOD: Single function with clear purpose
def invoke_mtproto_impl(method, params_json, allow_dangerous=False, resolve=True):
# Does everything in one logical flow
2. Constant Extraction
# ❌ BAD: Duplicate constants across files
# In file1.py
DANGEROUS_METHODS = {"messages.DeleteMessages", ...}
# In file2.py
DANGEROUS_METHODS = {"messages.DeleteMessages", ...}
# ✅ GOOD: Centralized constants
# In constants.py
DANGEROUS_METHODS = {
"account.DeleteAccount",
"messages.DeleteHistory",
"messages.DeleteMessages",
# ...
}
3. Helper Function Extraction
# ❌ BAD: Logic scattered in main function
def main_function():
# 50 lines of mixed logic
if "." not in method_name:
raise ValueError("Invalid format")
module_name, class_name = method_name.rsplit(".", 1)
# ... more mixed logic
# ✅ GOOD: Clear separation with helpers
def _resolve_method_class(method_name):
"""Resolve method name to Telethon class"""
if "." not in method_name:
raise ValueError("Invalid format")
# ... focused logic
def main_function():
method_cls = _resolve_method_class(method_name)
# ... clean main logic
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.
- 1mo ago First seen · 239 lines · 0 tokens per session scan A 20c4279f8806
code-optimization is a cursor rule published in the GitHub repository leshchenko1979/fast-mcp-telegram (49 stars, last pushed 9d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,404 tokens. 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-30.
Other cursor rules, from other repositories
refactoring
Refactoring: systematic approach, extract/inline, guard clauses, early returns.
clean-code
Clean code: naming, functions, simplicity.
code-review
Code review: reviewing approach, authoring PRs, feedback conventions.
git-workflow
Git workflow: commits, branches, PRs, history management.
example
You are in a workspace with Bifrost MCP tools enabled. Use them for code navigation, understanding, and modification. Follow these guidelines.
review
Structured code review with severity ratings — CRITICAL/HIGH/MEDIUM/LOW.