sayna / rules
Cursor rule314 starsChanged 12 months agoApache-2.0View on GitHub
We are using LiveKit Rust SDK livekit-rust for our real-time communication needs. The idea is that we should have a separate folder named livekit in the src folder. That folder should contain the main logic for connecting to the livekit server and receiving the audio chunks from subscribed tracks. Basically, user should be able to send the Websocket API message containing the livekit token to connect to the livekit server as a part of the websocket initial message. Then after…
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 1,533 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 repository5 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .cursor/rules/axum.mdcCursor rule
- .cursor/rules/core.mdcCursor rule
- .cursor/rules/openapi.mdcCursor rule
- .cursor/rules/rust.mdcCursor rule
The file
We split this livekit.mdc into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 75
After getting this message along side with the initial configuration message, we should do the following:
- Distinctive: line 78
Make sure that the published track is not the current localParticipant track, for not getting the same audio chunks twice
- Distinctive: line 80
When the Livekit User leaves the room, we should unsubscribe from the audio track and disconnect from the livekit server
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 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:
globs:
alwaysApply: false
---
We are using LiveKit Rust SDK [livekit-rust](https://github.com/livekit/livekit-rust) for our real-time communication needs.
The idea is that we should have a separate folder named `livekit` in the `src` folder. That folder should contain the main logic for connecting to the livekit server and receiving the audio chunks from subscribed tracks.
Basically, user should be able to send the Websocket API message containing the livekit token to connect to the livekit server as a part of the websocket initial message.
Then after we subscribe to the audio track, for the incoming audio chunks, we should send the received audio chunks to the Websocket audio callback. Similarly, how we process the audio chunks right now using websocket incoming audio chunks with a callback.
### Basic LiveKit Example
This code below connects to the livekit server and subscribes to the audio tracks.
```rust
use livekit::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
let (room, mut room_events) = Room::connect(&url, &token).await?;
while let Some(event) = room_events.recv().await {
match event {
RoomEvent::TrackSubscribed { track, publication, participant } => {
// ...
}
_ => {}
}
}
Ok(())
}
```
This code below gets the audio chunks from the subscribed track.
```rust
...
use futures::StreamExt; // this trait is required for iterating on audio & video frames
use livekit::prelude::*;
match event {
RoomEvent::TrackSubscribed { track, publication, participant } => {
match track {
RemoteTrack::Audio(audio_track) => {
let rtc_track = audio_track.rtc_track();
let mut audio_stream = NativeAudioStream::new(rtc_track);
tokio::spawn(async move {
// Receive the audio frames in a new task
while let Some(audio_frame) = audio_stream.next().await {
log::info!("received audio frame - {audio_frame:#?}");
}
});
},
}
},
_ => {}
}
```
## Websocket API Logic that should be implemented
During the initial configuration message, we should have the special JSON field object `livekit` that contains the livekit token and the related configuration as it is displayed below:
```json
{
....
"livekit": {
"token": "livekit_token",
"url": "http://localhost:7880",
}
}
```
After getting this message along side with the initial configuration message, we should do the following:
1. Connect to the livekit server using the token and the url
2. Subscribe to the audio track publications
3. Make sure that the published track is not the current localParticipant track, for not getting the same audio chunks twice
4. Subscribe to the audio track and get the audio chunks to the same callback where we receive the audio binary chunks from the websocket
5. When the Livekit User leaves the room, we should unsubscribe from the audio track and disconnect from the livekit server
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.

