

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# Deno Development Guide for GitHub Copilot23## Network Access45The development tools in this repository need network access to function. When6running `tools/format.js` or `tools/lint.js`, ensure the following domains are7reachable:89- `https://jsr.io` — Deno's package registry, used for `@std/*` imports10- `https://dprint.dev` and `https://plugins.dprint.dev` — the formatter11 (`tools/format.js`) runs `npm:dprint` which downloads WASM plugins from12 `plugins.dprint.dev`1314If you are running in a sandboxed environment, you must allowlist these domains15or the tools will fail with network errors.1617## High Level Overview1819The user-visible interface and high-level integration is in the `deno` crate20(located in `./cli`).2122This includes flag parsing, subcommands, package management tooling, etc. Flag23parsing is in `cli/args/flags.rs`. Tools are in `cli/tools/<tool>`.2425The `deno_runtime` crate (`./runtime`) assembles the JavaScript runtime,26including all of the "extensions" (native functionality exposed to JavaScript).27The extensions themselves are in the `ext/` directory, and provide system access28to JavaScript — for instance filesystem operations and networking.2930### Key Directories3132- `cli/` — User-facing CLI implementation, subcommands, and tools33- `runtime/` — JavaScript runtime assembly and integration34- `ext/` — Extensions providing native functionality to JS (fs, net, etc.)35- `libs/` — Shared Rust crates (core, resolver, npm, node_resolver, serde_v8,36 etc.)37- `tests/specs/` — Integration tests (spec tests)38- `tests/unit/` — Unit tests39- `tests/testdata/` — Test fixtures and data files4041### Key Files to Understand First42431. `cli/main.rs` — Entry point, command routing442. `cli/args/flags.rs` — CLI flag parsing and structure453. `runtime/worker.rs` — Worker/runtime initialization464. `runtime/permissions.rs` — Permission system475. `cli/module_loader.rs` — Module loading and resolution4849### Common Patterns5051- **Ops** — Rust functions exposed to JavaScript (in `ext/` directories)52- **Extensions** — Collections of ops and JS code providing functionality53- **Workers** — JavaScript execution contexts (main worker, web workers)54- **Resources** — Managed objects passed between Rust and JS (files, sockets,55 etc.)5657## Building5859```bash60# Check for compilation errors (fast, no binary output)61cargo check6263# Build debug binary64cargo build --bin deno6566# Build release version (slow, optimized)67cargo build --release6869# Run the dev build70./target/debug/deno eval 'console.log("Hello from dev build")'71```7273## Code Quality7475Before committing, always run the formatter and linter:7677```bash78# Format all code (uses dprint under the hood)79./tools/format.js8081# Lint all code (JS + Rust via clippy)82./tools/lint.js8384# Lint only JS/TS (faster, skips clippy)85./tools/lint.js --js8687# Lint only Rust88./tools/lint.js --rs89```9091The formatter (`tools/format.js`) runs `dprint` via `npm:dprint@0.47.2`. It92formats TypeScript, JavaScript, JSON, Markdown, YAML, and Rust (via `rustfmt`).93Configuration is in `.dprint.json`.9495The linter (`tools/lint.js`) runs `deno lint` for JS/TS and `cargo clippy` for96Rust.9798## Testing99100```bash101# Run all tests102cargo test103104# Filter tests by name105cargo test <nameOfTest>106107# Run tests in a specific package108cargo test -p deno_core109110# Run just the CLI integration tests111cargo test --bin deno112113# Run spec tests only114cargo test specs115116# Run a specific spec test117cargo test spec::test_name118```119120### Test Organization121122- **Spec tests** (`tests/specs/`) — Main integration tests123- **Unit tests** — Inline with source code in each module124- **Integration tests** (`tests/integration/`) — Additional integration tests125- **WPT** (`tests/wpt/`) — Web Platform Tests for web standards compliance126127### Spec Tests128129The main form of integration test is the "spec" test in `tests/specs/`. Each130test has a `__test__.jsonc` file describing CLI commands to run and expected131output. The schema is in `tests/specs/schema.json`.132133Example `__test__.jsonc`:134135```jsonc136{137 "tests": {138 "basic_case": {139 "args": "run main.ts",140 "output": "expected.out"141 }142 }143}144```145146Output assertions support wildcards:147148- `[WILDCARD]` — matches 0 or more characters (crosses newlines)149- `[WILDLINE]` — matches to end of line150- `[WILDCHAR]` — matches one character151- `[WILDCHARS(N)]` — matches N characters152- `[UNORDERED_START]` / `[UNORDERED_END]` — matches lines in any order153154## Git Workflow and Pull Requests155156### PR Title Linting157158PR titles are validated by CI (see `.github/workflows/pr.ts`). The title must159follow [Conventional Commits](https://www.conventionalcommits.org) and start160with one of these prefixes:161162- `feat:` — new features163- `fix:` — bug fixes164- `chore:` — maintenance tasks165- `perf:` — performance improvements166- `ci:` — CI changes167- `cleanup:` — code cleanup168- `docs:` — documentation169- `bench:` — benchmarks170- `build:` — build system changes171- `refactor:` — refactoring172- `test:` — test changes173- `Revert` — reverting a previous commit174- `Reland` — relanding a reverted commit175- `BREAKING` — breaking changes176177Additionally, deno_core/v8 upgrades must NOT use `chore:` — use `feat:`, `fix:`,178or `refactor:` instead, with a title describing the actual change.179180Release PRs (titles matching `X.Y.Z`) are also valid.181182The validation script is at `tools/verify_pr_title.js`.183184### Workflow Rules185186- Create feature branches with descriptive names187- Commit with clear, descriptive messages188- Never force push — all commits are squashed on merge189- Keep changes minimal and focused; avoid drive-by changes190- Before committing, run `tools/format.js` and `tools/lint.js`191192## Development Workflows193194### Adding a New CLI Subcommand1951961. Define the command structure in `cli/args/flags.rs`1972. Add the command handler in `cli/tools/<command_name>.rs` or198 `cli/tools/<command_name>/mod.rs`1993. Wire it up in `cli/main.rs`2004. Add spec tests in `tests/specs/<command_name>/`201202### Modifying or Adding an Extension2032041. Navigate to `ext/<extension_name>/`2052. Rust code provides the ops exposed to JavaScript2063. JavaScript code in the extension provides higher-level APIs2074. Update `runtime/worker.rs` to register a new extension2085. Add tests in the extension's directory209210## Debugging211212```bash213# Verbose logging214DENO_LOG=debug ./target/debug/deno run script.ts215216# Module-specific logging217DENO_LOG=deno_core=debug ./target/debug/deno run script.ts218219# Full backtrace on panic220RUST_BACKTRACE=1 ./target/debug/deno run script.ts221222# V8 inspector223./target/debug/deno run --inspect-brk script.ts224```225226In Rust code: `eprintln!("Debug: {:?}", var);` or `dbg!(var);`227228## Pull Request Reviews229230### Before commenting, verify your claims231232- If you claim something is missing (a stub, a test, error handling), search the233 full diff AND the existing codebase before commenting. Do not flag missing234 code that already exists elsewhere in the PR or the repository.235- If you suggest a code change, verify it compiles and does not break the236 intended behavior. Do not suggest fixes that contradict the PR's stated goal.237- Do not duplicate your own comments. If you already flagged an issue, do not238 post a second comment about the same thing.239240### Focus on high-value issues241242Prioritize these (in order):2432441. **Correctness bugs** — logic errors, race conditions (e.g. spurious wakeups245 on `Condvar`), use-after-free, null derefs2462. **Public API leaks** — internal fields accidentally exposed in public return247 types2483. **Security** — unsafe blocks with incorrect safety invariants, unsanitized249 inputs at system boundaries2504. **Missing error handling** — errors silently swallowed where they should251 propagate, or propagated where they should be caught252253Do NOT comment on:254255- Style preferences already enforced by the project's formatter (dprint) and256 linter (clippy + deno lint)257- Suggesting longer timeouts or shorter delays in tests without evidence of258 flakiness259- Minor documentation wording unless it is actively misleading260- Hypothetical edge cases that cannot realistically occur (e.g. a process having261 > 256 direct children)262263### Understand the runtime model before suggesting fixes264265Deno embeds V8 and uses a single-threaded async event loop (tokio). Code that266looks like a busy-spin may actually be required because:267268- `poll_sessions(None)` in the inspector drives async I/O — parking the thread269 prevents WebSocket close frames from being processed, causing deadlocks270- The event loop must keep running for futures to make progress; blocking the271 main thread stops the I/O reactor272- Some loops intentionally spin to allow the waker/poller to process events each273 iteration274275Before suggesting `sleep`, `park`, or backoff in a polling loop, check whether276the loop body drives async I/O that would stall if the thread were blocked.277278### Trace through the actual code path, not just the function signature279280A common review mistake is looking at a function's local behavior without281tracing its callers and the runtime context. For example:282283- A function that "doesn't check field X" may not need to because callers284 guarantee X is consumed before the check runs (e.g., `handshake` is always285 `take()`n at the top of `poll_sessions` before any session-count checks)286- A heuristic that "doesn't handle case Y" may already handle it through a287 different code path (e.g., dotenv comment detection via `#` prefix check288 happens before the inner-quote fallback is reached)289290### Don't suggest fixes that introduce circular dependencies291292In parsers and state machines, be careful not to suggest fixes that require293knowing the answer to the question being solved. For example, suggesting "detect294where the comment starts before matching quotes" is circular when the quote295matching is what determines where the value (and thus the comment) begins.296297### Verify suggestions against existing tests298299Before suggesting a change, check whether the codebase already has test coverage300for the case in question. The `test_valid_env` test in `libs/dotenv/lib.rs`301covers many edge cases including inline comments with quotes302(`EDGE_CASE_INLINE_COMMENTS`). Running existing tests before and after a303suggested change catches regressions.304305### Match existing patterns in the codebase306307When suggesting changes to a function, look for similar functions nearby that308solve analogous problems. If the existing pattern (e.g., `wait_for_session`)309uses a specific flag/mechanism, understand why before suggesting a different310approach for a similar function (e.g., `wait_for_sessions_disconnect`). The311difference may be intentional.312313### Deno-specific conventions314315- Ops use the `#[op2]` macro. Fast ops use `#[op2(fast)]`.316- Internal symbols in JS (`ext/process/40_process.js`, `ext/node/polyfills/`)317 use the `k` prefix convention: `kIpc`, `kSerialization`, `kInputOption`. Flag318 deviations.319- Node.js compatibility code is in `ext/node/polyfills/`. When reviewing these320 files, check behavior against Node.js docs, not just Deno conventions. Some321 patterns (like synchronous `throw` in `spawn()` for EPERM but async error322 event for ENOENT) are intentional Node.js compatibility.323324### When suggesting error handling changes325326- Check whether the function's callers expect the error to propagate or be327 swallowed. Do not suggest propagating errors in paths that are intentionally328 best-effort (e.g. killing already-exited processes).329- When suggesting a specific error variant or code change, verify the types330 actually match. For example, `Option::or_else` takes `FnOnce() -> Option<T>`,331 not `FnOnce(E) -> ...`.332- If a Rust function returns `Result` and an `Option` is needed, use `.ok()`333 before `.or_else()` or `.unwrap_or()`.334335### Platform-specific code336337- `#[cfg(unix)]` code that calls `find_descendant_pids` or similar must have338 stubs for non-Linux/non-macOS Unix targets. Check that339 `#[cfg(all(unix, not(target_os = "linux"), not(target_os = "macos")))]` stubs340 exist before flagging missing platform support.341- Windows `unsafe` blocks using `windows_sys` are common for process management.342 Verify handle cleanup (`CloseHandle`) but do not flag the `unsafe` usage343 itself.344345## Troubleshooting346347- **Slow compile times**: Use `cargo check`, `--bin deno`, or `sccache`348- **Build failures on macOS**: Run `xcode-select --install`349- **Build failures on Linux**: Install `build-essential`350- **Spec test failures**: Check output diffs, use `[WILDCARD]` for351 non-deterministic parts352- **Permission errors**: Ensure test files have correct permissions353
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| denoland/denoCLAUDE.md · 108k | CLAUDE.md | setupbuildtestlint-format+9 | 89/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| louislam/uptime-kuma.github/copilot-instructions.md · 90k | Copilot instructions | setupbuildtestlint-format+9 | 100/100 | 14 days ago | |
| HerringtonDarkholme/megarepo.github/copilot-instructions.md · 17 | Copilot instructions | setupbuildtestlint-format+7 | 100/100 | 14 days ago | |
| chihebnabil/lovable-boilerplate.github/instructions/global.instructions.md · 65 | Copilot instructions | buildlint-formatstylearch+4 | 100/100 | 14 days ago | |
| rtk-ai/rtk.github/copilot-instructions.md · 76k | Copilot instructions | buildtestlint-formatstyle+2 | 97/100 | 14 days ago | |
| bagisto/bagisto.github/copilot-instructions.md · 28k | Copilot instructions | setupbuildteststyle+5 | 97/100 | 14 days ago | |
| JCodesMore/ai-website-cloner-template.github/copilot-instructions.md · 32k | Copilot instructions | buildlint-formatstylearch+3 | 97/100 | 7 days ago | |
| darkmatter/nixmac.github/copilot-instructions.md · 25 | Copilot instructions | setupbuildtestlint-format+8 | 96/100 | 14 days ago | |
| nerolis-lab/nerolis-lab.github/copilot-instructions.md · 32 | Copilot instructions | setupbuildtestlint-format+11 | 96/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/denoland-deno-github-copilot-instructions)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.