db-conventions
Skill4.2k starsChanged 36 days agoMITView on GitHub
Data-layer invariants for the collector — SQLite patterns, transactions, time keys, backendId isolation, ClickHouse read/write topology. Use when writing queries, touching repositories, or debugging data drift.
1 other project uses a version of this.
Trending
Quiet since August.thin dataabout the whole repository
Most recently taken up by
- foru17/clash-masterword for word, first seen Oct 8, 2026
Who's talking about foru17/neko-master
- @camilleroux.com“Neko Master : un dashboard self-hosted pour visualiser et auditer le trafic réseau en temps réel, avec …”Bluesky · Aug 3, 2026 · 4 likes
- @github-trending-js.bsky.social“🚀 Skyrocketing! 🚀 (200+ new stars) 📦 foru17 / neko-master ⭐ 3,679 (+231) 🗒 TypeScript A modern and …”Bluesky · Aug 21, 2026 · 1 likes
- @chrisshort.net“foru17/neko-master: A modern and elegant dashboard for network traffic visualization and analysis. …”Bluesky · Jul 24, 2026 · 1 likes
- @github-trending-js.bsky.social“🔥 Hot Repo! 🔥 (100+ new stars) 📦 foru17 / neko-master ⭐ 2,741 (+186) 🗒 TypeScript A modern and elegant …”Bluesky · Jul 17, 2026 · 1 likes
- ruanyf/weekly“【开源自荐】Neko Master:现代化网络流量分析面板”GitHub · Feb 11, 2026
The biggest 5 of 5 mentions linking to the repository that our crawl found. Each line is their own headline.
Other versions1 project uses a version of this.
Word for word · 1
- foru17/clash-master★ 4.2k100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- add-stats-dimensionSkill
- agent-probe-devSkill
- releaseSkill
- ui-conventionsSkill
- verify-changesSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
One write path: All traffic stats go through batchUpdateTrafficStats (database/repositories/traffic-writer.repository.ts).
- Very specific: line 14
backendId isolation everywhere: Every stats table, query, and cache key is scoped by backend_id.
- Distinctive: line 25
Read/write behavior is controlled by env flags — keep them coherent:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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
Data Layer Conventions (apps/collector)
Invariants (breaking any of these has bitten us before)
- One write path. All traffic stats go through
batchUpdateTrafficStats(database/repositories/traffic-writer.repository.ts); the whole flush is a single outer transaction (innerdb.transaction()calls degrade to savepoints). Never commit table groups independently — a mid-flush failure plus buffer retry double-counts. - Rule name = policy group. For multi-hop chains the aggregation key is the last chain hop (the user's policy group), produced only by
buildRuleName(shared/utils/rule-name.ts). Rule type + payload (RuleSet(foo)) is the key only for single-hop DIRECT/REJECT chains. The web flow graph and gateway-rule matching depend on this. - Delimiter-aware CSV dedup. Comma-list columns dedupe with
INSTR(',' || col || ',', ',' || @v || ',')— bareINSTRsubstring-matches (a.cominsideaa.com) and silently drops values. Lists are capped atLENGTH > 4000. - UTC time keys. Minute
YYYY-MM-DDTHH:MM:00, hourYYYY-MM-DDTHH:00:00, viatoMinuteKey/toHourKey(base.repository.ts). No local-time truncation. - backendId isolation everywhere. Every stats table, query, and cache key is scoped by
backend_id.PRAGMA foreign_keysis OFF — deleting a backend relies on the explicit table list indeleteBackendData; new tables must be added there. - Range routing. Range queries route by span in
resolveFactTable(base.repository.ts): ≤6h →minute_dim_stats, >6h →hourly_dim_stats. Retention must respect this: hourly dim tables followhourlyStatsDays, minute tables followconnectionLogsDays.
SQLite usage
- better-sqlite3, synchronous — long scans and big transactions block the event loop shared with WS ingest. Cap query result sets (
LIMIT), useMapmerges instead of nestedfindIndex, and prefer prepared statements cached on the instance for hot paths. - WAL mode with tuned pragmas is set in
modules/db/db.tsinit()(env-tunable:SQLITE_CACHE_MB,SQLITE_WAL_AUTOCHECKPOINT_PAGES,SQLITE_BUSY_TIMEOUT_MS). - Migrations are ad-hoc in
init()— idempotent (IF NOT EXISTS/ try-catch ALTER / app_config flags for one-time data migrations, seedatabase/rule-name-cleanup.tsas the reference pattern).
ClickHouse topology
Read/write behavior is controlled by env flags — keep them coherent:
| Flag | Meaning |
CH_WRITE_ENABLED | Write traffic batches to ClickHouse |
STATS_QUERY_SOURCE | sqlite (default) / clickhouse / auto — read routing |
CH_ONLY_MODE=1 | Skip SQLite stats writes entirely (requires healthy CH writer) |
CH_STRICT_STATS=1 | Fail instead of silently falling back to SQLite reads |
Guard rails already enforced in code (modules/stats/stats-write-mode.ts): reduced SQLite writes require reads to actually prefer ClickHouse — don't bypass shouldReduceSqliteWrites/shouldSkipSqliteStatsWrites with ad-hoc env checks. When adding a range query, implement BOTH the SQLite repository method and the clickhouse.reader.ts counterpart with identical semantics, and route via a *WithRouting method in stats.service.ts.
Partial-failure contract
BatchBuffer.flush returns per-group outcomes (detailOk/aggOk); the realtime store is only cleared for the groups that durably persisted. When touching flush/clear logic, preserve this contract — it is the data-loss protection added in v1.3.9.
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.

