Skip to content

Commit c6fb70d

Browse files
authored
Merge pull request #1 from chainstacklabs/add-agents-md
Add AGENTS.md
2 parents a6104a9 + c5d6afe commit c6fb70d

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed

AGENTS.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# AGENTS Guidelines for This Repository
2+
3+
This repository contains a Solana Yellowstone gRPC Geyser tutorial and examples. When working on the project interactively with an agent (e.g. the Codex CLI) please follow the guidelines below for efficient development and testing.
4+
5+
## 1. Use Learning Examples for Testing
6+
7+
* **Always test with learning examples** in `learning-examples/` before creating new monitors.
8+
* **Start with basic filters** before implementing complex ones.
9+
* **Monitor connection stability** when running long-term subscriptions.
10+
* **Use `PROCESSED` commitment** for fastest updates during development.
11+
12+
## 2. Keep Dependencies in Sync
13+
14+
If you add or update dependencies:
15+
16+
1. Use `uv add <package>` to add new dependencies.
17+
2. The `uv.lock` file will be automatically updated.
18+
3. Verify compatibility with Python 3.13+ as specified in the project.
19+
20+
## 3. Protocol Buffer Management
21+
22+
When working with proto files:
23+
24+
* Keep proto files in sync with the official Yellowstone repository.
25+
* After regenerating client code, fix imports in generated files:
26+
- In `geyser_pb2.py`: Change absolute imports to relative imports
27+
- In `geyser_pb2_grpc.py`: Change absolute imports to relative imports
28+
* Never edit generated files directly except for import fixes.
29+
30+
## 4. Code Quality Checks
31+
32+
Before completing any task, run these quality checks:
33+
34+
| Command | Purpose |
35+
| ------------------ | --------------------------------- |
36+
| `uv run ruff format` | Format code to standards |
37+
| `uv run ruff check` | Run linting checks |
38+
| `uv run ruff check --fix` | Auto-fix linting issues |
39+
40+
## 5. Environment Configuration
41+
42+
Create a `.env` file with required credentials (never commit):
43+
44+
```env
45+
GEYSER_ENDPOINT=YOUR_YELLOWSTONE_GRPC_ENDPOINT
46+
GEYSER_API_TOKEN=YOUR_API_TOKEN
47+
```
48+
49+
## 6. Testing Workflow
50+
51+
Test changes progressively:
52+
53+
1. **Connection test**: Verify gRPC connection first
54+
```bash
55+
uv run learning-examples/slots_subscription.py
56+
```
57+
58+
2. **Basic filters**: Test simple subscriptions
59+
```bash
60+
uv run learning-examples/accounts_basic_filter.py
61+
uv run learning-examples/transactions_basic_filter.py
62+
```
63+
64+
3. **Advanced filters**: Test complex filtering logic
65+
```bash
66+
uv run learning-examples/accounts_advanced_filter.py
67+
uv run learning-examples/transactions_advanced_filter.py
68+
```
69+
70+
4. **Main application**: Test complete implementation
71+
```bash
72+
uv run main.py
73+
```
74+
75+
## 7. Development Best Practices
76+
77+
* Use type hints for all function parameters and returns.
78+
* Include docstrings explaining filter purposes.
79+
* Handle connection errors gracefully with retries.
80+
* Implement keepalive options for long-running subscriptions.
81+
* Log important events for debugging.
82+
83+
## 8. Common Development Tasks
84+
85+
### Regenerate Proto Files
86+
```bash
87+
# Download latest proto files
88+
curl -o proto/geyser.proto https://raw.githubusercontent.com/rpcpool/yellowstone-grpc/master/yellowstone-grpc-proto/proto/geyser.proto
89+
curl -o proto/solana-storage.proto https://raw.githubusercontent.com/rpcpool/yellowstone-grpc/master/yellowstone-grpc-proto/proto/solana-storage.proto
90+
91+
# Generate Python code
92+
uv run --with grpcio-tools -- python -m grpc_tools.protoc \
93+
--python_out=./generated \
94+
--grpc_python_out=./generated \
95+
--proto_path=./proto \
96+
geyser.proto solana-storage.proto
97+
98+
# Fix imports manually in generated files
99+
```
100+
101+
### Add New Learning Example
102+
1. Create new file in `learning-examples/`
103+
2. Follow existing patterns for connection and subscription setup
104+
3. Document the specific use case in comments
105+
4. Test thoroughly before committing
106+
107+
## 9. Subscription Types Reference
108+
109+
| Type | Use Case | Example File |
110+
| ---- | -------- | ------------ |
111+
| Accounts | Monitor specific account changes | `accounts_basic_filter.py` |
112+
| Transactions | Track transaction activity | `transactions_basic_filter.py` |
113+
| Slots | Monitor slot progression | `slots_subscription.py` |
114+
| Blocks | Subscribe to full blocks | `blocks_subscription.py` |
115+
| Block Metadata | Lightweight block tracking | `blocks_meta_subscription.py` |
116+
| Entries | Low-level ledger changes | `entries_subscription.py` |
117+
| Transaction Status | Track tx finalization | `transaction_statuses_subscription.py` |
118+
119+
## 10. Useful Commands Recap
120+
121+
| Command | Purpose |
122+
| ------------------------------------------ | -------------------------------- |
123+
| `uv sync` | Install/update dependencies |
124+
| `uv run main.py` | Run the main monitor |
125+
| `uv run learning-examples/<example>.py` | Run specific example |
126+
| `uv run ruff format` | Format code |
127+
| `uv run ruff check` | Lint code |
128+
129+
## 11. Safety Reminders
130+
131+
* **Never expose API tokens** in code or commits.
132+
* **Test filters carefully** to avoid overwhelming the gRPC endpoint.
133+
* **Monitor rate limits** and connection stability.
134+
* **Handle disconnections gracefully** with retry logic.
135+
* **Log errors** for debugging connection issues.
136+
137+
---
138+
139+
Following these practices ensures reliable Geyser development, prevents connection issues, and maintains code quality. Always test filters progressively from simple to complex when developing new monitoring capabilities.

0 commit comments

Comments
 (0)