Agent skill
telegram-gateway-debug-loop
Debug and stress-test lemon gateway behavior by acting as both sides of Telegram conversations: run lemon-gateway with debug logs, then use Telethon with user credentials to send/reply messages in a dedicated topic while watching gateway logs and runtime state. Use for stuck runs, delivery failures, scheduler/lock contention, async delegation bugs, and context overflows.
Install this agent skill to your Project
npx add-skill https://github.com/z80dev/lemon/tree/main/.claude/skills/telegram-gateway-debug-loop
SKILL.md
Telegram Gateway Debug Loop
Use this skill to run end-to-end repros with real Telegram traffic.
Setup
-
Load Telegram credentials from
~/.zeebot/api_keys/telegram.txt.- Read the file to get
api_id,api_hash, and phone number. - NEVER print, echo, or commit these values. Hold them in memory only.
- Read the file to get
-
Start gateway with debug logging:
bashcd /Users/z80/dev/lemon LOG_LEVEL=debug ./bin/lemon-gateway --debug --sname lemon_gateway_debugRun this in the background and monitor its output.
-
Optionally attach a remote shell for live introspection:
bashiex --sname lemon_attach --cookie lemon_gateway_dev_cookie --remsh lemon_gateway_debug@$(hostname -s)
Sending Messages via Telethon
-
Use Telethon through
uv(no global install needed):bashuv run --with telethon python <script.py>Write a temporary Python script that:
- Connects with the user's Telegram credentials
- Sends messages into a dedicated debug topic/thread
- Keeps all probes in that thread
-
Stress async behavior with prompts that trigger delegation/tool runs:
agent_id=coderdelegation- Async poll loops
- Multi-step tool workflows
Inspecting Runtime State
- While traffic is active, inspect runtime state via the remote shell:
:sys.get_state(LemonGateway.Scheduler)— scheduler state:sys.get_state(LemonGateway.EngineLock)— lock stateDynamicSupervisor.which_children(LemonGateway.ThreadWorkerSupervisor)— active workers
Watching for Failures
- Watch gateway logs for high-value failure signatures:
:unknown_channel— message routed to unknown channel- Scheduler stalls or lock starvation
- Context overflow/trim failures
- Delivery retries/timeouts
Capturing Repros
- For each repro, capture:
- The exact prompt(s) sent
- Thread ID
- Timestamps
- State snapshots from the remote shell
- Relevant log lines
If $ARGUMENTS is provided, focus the debug session on reproducing that specific issue.
Secrets + Safety
- NEVER print or commit API keys, session strings, OTPs, or phone numbers.
- Keep credentials in local secret files only.
- If session auth is invalid, re-auth locally and update only local secret files.
- Do not include credentials in any script files that get written to disk — pass them via environment variables or read them at runtime.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
summarize
Summarize or extract text/transcripts from URLs, podcasts, and local files (great fallback for “transcribe this YouTube/video”).
pinata
Pin files and JSON to IPFS via Pinata (JWT auth + helper scripts).
tmux
Remote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output.
github
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
peekaboo
Capture and automate macOS UI with the Peekaboo CLI.
runtime-remsh
Connect to a running Lemon or lemon-gateway BEAM node, run recompile() for hot code reload, and execute Elixir code in that live runtime via IEx remsh or rpc-eval.
Didn't find tool you were looking for?