@yuaone/core 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-loop.d.ts +62 -0
- package/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +705 -18
- package/dist/agent-loop.js.map +1 -1
- package/dist/background-agent.d.ts +110 -0
- package/dist/background-agent.d.ts.map +1 -0
- package/dist/background-agent.js +255 -0
- package/dist/background-agent.js.map +1 -0
- package/dist/coding-standards.d.ts +45 -0
- package/dist/coding-standards.d.ts.map +1 -0
- package/dist/coding-standards.js +1152 -0
- package/dist/coding-standards.js.map +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -6
- package/dist/constants.js.map +1 -1
- package/dist/context-manager.d.ts +6 -0
- package/dist/context-manager.d.ts.map +1 -1
- package/dist/context-manager.js +23 -4
- package/dist/context-manager.js.map +1 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/dist/llm-client.d.ts +8 -3
- package/dist/llm-client.d.ts.map +1 -1
- package/dist/llm-client.js +64 -13
- package/dist/llm-client.js.map +1 -1
- package/dist/plugin-auto-loader.d.ts +108 -0
- package/dist/plugin-auto-loader.d.ts.map +1 -0
- package/dist/plugin-auto-loader.js +743 -0
- package/dist/plugin-auto-loader.js.map +1 -0
- package/dist/plugin-registry.d.ts +112 -0
- package/dist/plugin-registry.d.ts.map +1 -0
- package/dist/plugin-registry.js +319 -0
- package/dist/plugin-registry.js.map +1 -0
- package/dist/plugin-types.d.ts +388 -0
- package/dist/plugin-types.d.ts.map +1 -0
- package/dist/plugin-types.js +8 -0
- package/dist/plugin-types.js.map +1 -0
- package/dist/plugin-validator.d.ts +54 -0
- package/dist/plugin-validator.d.ts.map +1 -0
- package/dist/plugin-validator.js +129 -0
- package/dist/plugin-validator.js.map +1 -0
- package/dist/repo-knowledge-graph.d.ts +112 -0
- package/dist/repo-knowledge-graph.d.ts.map +1 -0
- package/dist/repo-knowledge-graph.js +561 -0
- package/dist/repo-knowledge-graph.js.map +1 -0
- package/dist/role-registry.js +1 -1
- package/dist/role-registry.js.map +1 -1
- package/dist/self-debug-loop.d.ts +257 -0
- package/dist/self-debug-loop.d.ts.map +1 -0
- package/dist/self-debug-loop.js +870 -0
- package/dist/self-debug-loop.js.map +1 -0
- package/dist/skill-learner.d.ts +136 -0
- package/dist/skill-learner.d.ts.map +1 -0
- package/dist/skill-learner.js +382 -0
- package/dist/skill-learner.js.map +1 -0
- package/dist/skill-loader.d.ts +90 -0
- package/dist/skill-loader.d.ts.map +1 -0
- package/dist/skill-loader.js +309 -0
- package/dist/skill-loader.js.map +1 -0
- package/dist/specialist-registry.d.ts +132 -0
- package/dist/specialist-registry.d.ts.map +1 -0
- package/dist/specialist-registry.js +413 -0
- package/dist/specialist-registry.js.map +1 -0
- package/dist/sub-agent-prompts.d.ts +45 -0
- package/dist/sub-agent-prompts.d.ts.map +1 -0
- package/dist/sub-agent-prompts.js +177 -0
- package/dist/sub-agent-prompts.js.map +1 -0
- package/dist/sub-agent-router.d.ts +75 -0
- package/dist/sub-agent-router.d.ts.map +1 -0
- package/dist/sub-agent-router.js +174 -0
- package/dist/sub-agent-router.js.map +1 -0
- package/dist/sub-agent.d.ts +48 -0
- package/dist/sub-agent.d.ts.map +1 -1
- package/dist/sub-agent.js +108 -5
- package/dist/sub-agent.js.map +1 -1
- package/dist/system-prompt.d.ts +26 -0
- package/dist/system-prompt.d.ts.map +1 -1
- package/dist/system-prompt.js +177 -7
- package/dist/system-prompt.js.map +1 -1
- package/dist/task-classifier.d.ts +25 -1
- package/dist/task-classifier.d.ts.map +1 -1
- package/dist/task-classifier.js +171 -1
- package/dist/task-classifier.js.map +1 -1
- package/dist/tool-planner.d.ts +160 -0
- package/dist/tool-planner.d.ts.map +1 -0
- package/dist/tool-planner.js +501 -0
- package/dist/tool-planner.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/world-state.d.ts.map +1 -1
- package/dist/world-state.js +8 -1
- package/dist/world-state.js.map +1 -1
- package/package.json +2 -1
- package/plugins/git/patterns/branch-patterns.json +101 -0
- package/plugins/git/patterns/commit-patterns.json +186 -0
- package/plugins/git/plugin.yaml +128 -0
- package/plugins/git/skills/branch-strategy.md +172 -0
- package/plugins/git/skills/commit-conv.md +178 -0
- package/plugins/git/skills/conflict-resolve.md +159 -0
- package/plugins/git/skills/history-clean.md +199 -0
- package/plugins/git/skills/pr-review.md +196 -0
- package/plugins/git/strategies/conflict-resolve.json +244 -0
- package/plugins/git/strategies/release-flow.json +292 -0
- package/plugins/git/validators/rules.json +348 -0
- package/plugins/react/patterns/anti-patterns.json +88 -0
- package/plugins/react/patterns/components.json +80 -0
- package/plugins/react/patterns/hooks.json +72 -0
- package/plugins/react/plugin.yaml +229 -0
- package/plugins/react/skills/bugfix.md +208 -0
- package/plugins/react/skills/component-gen.md +206 -0
- package/plugins/react/skills/hook-extract.md +208 -0
- package/plugins/react/skills/ssr.md +256 -0
- package/plugins/react/skills/test.md +273 -0
- package/plugins/react/strategies/build-fix.json +43 -0
- package/plugins/react/strategies/hook-loop-fix.json +36 -0
- package/plugins/react/strategies/hydration-fix.json +42 -0
- package/plugins/react/validators/rules.json +92 -0
- package/plugins/typescript/patterns/best-practices.json +25 -0
- package/plugins/typescript/patterns/common-errors.json +32 -0
- package/plugins/typescript/plugin.yaml +74 -0
- package/plugins/typescript/skills/debug.md +23 -0
- package/plugins/typescript/skills/migration.md +24 -0
- package/plugins/typescript/skills/refactor.md +22 -0
- package/plugins/typescript/skills/strict-mode.md +23 -0
- package/plugins/typescript/strategies/strict-migration.json +37 -0
- package/plugins/typescript/strategies/type-error-fix.json +37 -0
- package/plugins/typescript/validators/rules.json +28 -0
|
@@ -0,0 +1,1152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module coding-standards
|
|
3
|
+
* @description Comprehensive language-specific coding best practices for sub-agents.
|
|
4
|
+
*
|
|
5
|
+
* Injected into system prompts when a language is detected.
|
|
6
|
+
* 50+ languages covered: systems, HDL, embedded, web, mobile, data, devops,
|
|
7
|
+
* functional, game, blockchain, emerging.
|
|
8
|
+
*
|
|
9
|
+
* Each standard: 150-250 tokens (concise rules, not essays).
|
|
10
|
+
*/
|
|
11
|
+
// ─── Registry ───
|
|
12
|
+
const STANDARDS = new Map();
|
|
13
|
+
function register(std) {
|
|
14
|
+
STANDARDS.set(std.name.toLowerCase(), std);
|
|
15
|
+
for (const alias of std.aliases) {
|
|
16
|
+
STANDARDS.set(alias.toLowerCase(), std);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// ═══════════════════════════════════════════════════════════════
|
|
20
|
+
// 1. SYSTEMS & LOW-LEVEL
|
|
21
|
+
// ═══════════════════════════════════════════════════════════════
|
|
22
|
+
register({
|
|
23
|
+
name: "C",
|
|
24
|
+
category: "systems",
|
|
25
|
+
aliases: ["c", "c99", "c11", "c17", "c23"],
|
|
26
|
+
standards: `Core rules:
|
|
27
|
+
- Every malloc must have a paired free. Set pointers to NULL after free. Check malloc return for NULL.
|
|
28
|
+
- Buffer overflow prevention: use snprintf over sprintf, strncpy over strcpy, bounds-check all array accesses.
|
|
29
|
+
- const-correctness: mark all read-only params as const. Use const for pointer-to-data (const char*) vs pointer itself (char* const).
|
|
30
|
+
- volatile for hardware registers and ISR-shared variables. Never cache volatile reads in local variables.
|
|
31
|
+
- Static analysis: zero warnings with -Wall -Wextra -Werror. MISRA-C compliance for safety-critical code.
|
|
32
|
+
Pitfalls: never return pointers to stack variables. Avoid undefined behavior (signed overflow, null deref, unsequenced modifications).
|
|
33
|
+
Performance: prefer stack allocation over heap. Use restrict for non-aliasing pointers. Profile before optimizing.
|
|
34
|
+
Safety: validate all external input lengths. Use fixed-size buffers with explicit bounds. No implicit integer conversions in security paths.`,
|
|
35
|
+
});
|
|
36
|
+
register({
|
|
37
|
+
name: "C++",
|
|
38
|
+
category: "systems",
|
|
39
|
+
aliases: ["cpp", "cc", "cxx", "c++", "c++17", "c++20", "c++23", "hpp"],
|
|
40
|
+
standards: `Core rules:
|
|
41
|
+
- RAII for all resource management. No manual new/delete — use smart pointers: unique_ptr > shared_ptr > raw.
|
|
42
|
+
- Move semantics: implement move constructor/assignment for resource-owning types. Use std::move for transfers.
|
|
43
|
+
- Rule of Five: if you define any of destructor/copy-ctor/copy-assign/move-ctor/move-assign, define all five.
|
|
44
|
+
- constexpr for compile-time computation. Prefer constexpr over macros and const for constants.
|
|
45
|
+
- Exception safety: basic guarantee minimum. Strong guarantee for critical operations. noexcept on move operations.
|
|
46
|
+
Pitfalls: avoid slicing (pass polymorphic types by reference/pointer). No raw owning pointers. Beware dangling references from temporaries.
|
|
47
|
+
Performance: reserve() containers when size is known. Prefer emplace_back over push_back. Use string_view for read-only string params.
|
|
48
|
+
Safety: enable -fsanitize=address,undefined in debug. Use [[nodiscard]] on functions whose return must not be ignored.`,
|
|
49
|
+
});
|
|
50
|
+
register({
|
|
51
|
+
name: "Rust",
|
|
52
|
+
category: "systems",
|
|
53
|
+
aliases: ["rs", "rust"],
|
|
54
|
+
standards: `Core rules:
|
|
55
|
+
- Ownership: prefer borrowing (&T, &mut T) over cloning. Move semantics by default — clone only when necessary.
|
|
56
|
+
- Result<T, E> for recoverable errors, Option<T> for absence. Propagate with ?. No .unwrap() in production — use .expect() with context or proper error handling.
|
|
57
|
+
- Lifetime annotations only when compiler requires them. Prefer owned types in structs over references.
|
|
58
|
+
- Trait bounds: use impl Trait in arguments, explicit bounds in generic structs. Derive common traits (Debug, Clone, PartialEq).
|
|
59
|
+
- unsafe: minimize and isolate. Document safety invariants with // SAFETY: comments. Encapsulate in safe abstractions.
|
|
60
|
+
Pitfalls: avoid RefCell unless truly needed (runtime borrow panics). Don't fight the borrow checker — redesign.
|
|
61
|
+
Performance: iterators over index loops. Use .collect() with turbofish. Prefer &str over String for read-only params.
|
|
62
|
+
Safety: run clippy (cargo clippy -- -D warnings). Use #[deny(unsafe_code)] at crate level for non-FFI crates. no_std for embedded targets.`,
|
|
63
|
+
});
|
|
64
|
+
register({
|
|
65
|
+
name: "Assembly",
|
|
66
|
+
category: "systems",
|
|
67
|
+
aliases: ["asm", "assembly", "x86", "arm", "aarch64", "mips", "riscv", "s"],
|
|
68
|
+
standards: `Core rules:
|
|
69
|
+
- Follow platform calling convention strictly: cdecl/System V AMD64 (x86-64), AAPCS (ARM), standard (RISC-V). Caller/callee-saved registers must be respected.
|
|
70
|
+
- Stack alignment: 16-byte on x86-64, 8-byte on ARM. Misalignment causes faults or silent performance loss.
|
|
71
|
+
- Comment every logical block: purpose, register usage, algorithm step. Label naming: module_function_purpose.
|
|
72
|
+
- Macro safety: avoid side effects in macro arguments. Use .macro/.endm (GAS) or MACRO/ENDM (MASM). Unique labels in macros with \\@ or LOCAL.
|
|
73
|
+
- Preserve frame pointer for debuggability unless in hot inner loops with profiling proof.
|
|
74
|
+
Pitfalls: don't assume register state across function calls. Clear direction flag (CLD) before string ops on x86. Beware endianness in multi-byte loads.
|
|
75
|
+
Performance: align branch targets. Minimize pipeline stalls — instruction scheduling matters. Use SIMD (SSE/AVX/NEON) for data parallelism.
|
|
76
|
+
Safety: never execute data. Mark stack non-executable. Validate all jump targets in JIT scenarios.`,
|
|
77
|
+
});
|
|
78
|
+
register({
|
|
79
|
+
name: "Zig",
|
|
80
|
+
category: "systems",
|
|
81
|
+
aliases: ["zig"],
|
|
82
|
+
standards: `Core rules:
|
|
83
|
+
- comptime for compile-time computation — replace macros and generics. comptime parameters for type-level programming.
|
|
84
|
+
- Error unions: return errors explicitly, handle with try/catch. No hidden control flow. Error sets are first-class types.
|
|
85
|
+
- No hidden allocations: all allocators are explicit parameters. Use std.mem.Allocator interface. Prefer arena/stack allocators for temporary data.
|
|
86
|
+
- Optional types (?T) for nullable values. Unwrap with orelse/if for safe access. Never assume non-null.
|
|
87
|
+
- C interop: use @cImport for headers. Zig pointers vs C pointers — mind sentinel-terminated ([*:0]u8) for C strings.
|
|
88
|
+
Pitfalls: comptime code runs at compile time — don't do I/O in comptime. Slices are fat pointers (ptr + len), not arrays.
|
|
89
|
+
Performance: SIMD via @Vector. Release-safe mode for production. Use @prefetch for memory access patterns.
|
|
90
|
+
Safety: safety checks enabled by default (bounds, overflow). Keep them on in release-safe. Disable only in release-fast with benchmarks.`,
|
|
91
|
+
});
|
|
92
|
+
// ═══════════════════════════════════════════════════════════════
|
|
93
|
+
// 2. HARDWARE DESCRIPTION LANGUAGES (HDL)
|
|
94
|
+
// ═══════════════════════════════════════════════════════════════
|
|
95
|
+
register({
|
|
96
|
+
name: "VHDL",
|
|
97
|
+
category: "hdl",
|
|
98
|
+
aliases: ["vhdl", "vhd"],
|
|
99
|
+
standards: `Core rules:
|
|
100
|
+
- Signal vs variable: signals update at end of process (concurrent), variables update immediately (sequential). Use signals for inter-process communication, variables for local computation.
|
|
101
|
+
- Process sensitivity lists MUST be complete — missing signals cause simulation/synthesis mismatch. Use (all) in VHDL-2008 for combinational logic.
|
|
102
|
+
- Synchronous design: all flip-flops clocked by single edge (rising_edge(clk)). Explicit reset strategy — synchronous reset preferred for FPGA, async for ASIC if required.
|
|
103
|
+
- Clock domain crossing (CDC): use 2-stage synchronizer for single-bit, handshake or async FIFO for multi-bit. Never directly sample signals across clock domains.
|
|
104
|
+
- Naming: snake_case for signals, UPPER_CASE for constants/generics. Prefix: i_ input, o_ output, r_ register, w_ wire, c_ constant.
|
|
105
|
+
Pitfalls: incomplete if/case creates latches — always have else/default. Avoid initial values on signals (not synthesizable on all targets).
|
|
106
|
+
Performance: pipeline long combinational paths. Register outputs for better timing. Use DSP blocks for multiplication.
|
|
107
|
+
Safety: DO-254 for avionics. Full testbench coverage with self-checking assertions. Use numeric_std, not std_logic_arith.`,
|
|
108
|
+
});
|
|
109
|
+
register({
|
|
110
|
+
name: "Verilog",
|
|
111
|
+
category: "hdl",
|
|
112
|
+
aliases: ["verilog", "v", "systemverilog", "sv"],
|
|
113
|
+
standards: `Core rules:
|
|
114
|
+
- Blocking (=) for combinational logic (always_comb), non-blocking (<=) for sequential logic (always_ff). Never mix in same block.
|
|
115
|
+
- SystemVerilog: use always_ff for flip-flops, always_comb for combinational, always_latch only when intentional. Avoid plain always @*.
|
|
116
|
+
- Avoid unintentional latches: every if needs else, every case needs default in combinational blocks. Use unique/priority case for full/parallel encoding.
|
|
117
|
+
- Parameterized modules: use parameter/localparam for configurability. Generate blocks for structural repetition. Interface for grouped signals.
|
|
118
|
+
- Assertions (SVA): assert property for functional verification. cover property for coverage. Bind assertions to modules from testbench.
|
|
119
|
+
Pitfalls: sensitivity list mismatch between simulation and synthesis. Don't read/write same signal in multiple always blocks. Beware integer overflow in loop bounds.
|
|
120
|
+
Performance: minimize clock-to-output delay. Balance pipeline stages. Use vendor-specific primitives (DSP, BRAM) for critical paths.
|
|
121
|
+
Safety: full CDC verification. Lint with tools like Spyglass/Verilator. Coverage-driven verification: line, toggle, FSM, assertion coverage targets >95%.`,
|
|
122
|
+
});
|
|
123
|
+
register({
|
|
124
|
+
name: "Chisel",
|
|
125
|
+
category: "hdl",
|
|
126
|
+
aliases: ["chisel"],
|
|
127
|
+
standards: `Core rules:
|
|
128
|
+
- Bundle for grouped signals (like VHDL record or SystemVerilog struct). Use Flipped() for input bundles in IO.
|
|
129
|
+
- RegNext for 1-cycle delay, RegInit for reset value, RegEnable for conditional update. Never use Reg without initialization in synthesizable code.
|
|
130
|
+
- when/elsewhen/otherwise for conditional logic (maps to mux). switch(enum) for FSMs with is() cases.
|
|
131
|
+
- Decoupled interface (valid/ready/bits) for handshake protocols. Use Queue() for FIFOs. Pipe() for pipeline stages.
|
|
132
|
+
- Module hierarchy: one module per file. Use lazy val io = IO(...). Parameters via case class config objects.
|
|
133
|
+
Pitfalls: Chisel Wire vs Reg — Wire for combinational, Reg for sequential. Don't connect same signal twice. DontCare for unused outputs.
|
|
134
|
+
Performance: use Mem for synchronous RAM inference. BlackBox for vendor IP integration. Annotations for physical constraints.
|
|
135
|
+
Safety: PeekPokeTester/ChiselTest for simulation. Use chiseltest fork/join for concurrent testing. Assert in hardware with assert() for runtime checks.`,
|
|
136
|
+
});
|
|
137
|
+
register({
|
|
138
|
+
name: "SpinalHDL",
|
|
139
|
+
category: "hdl",
|
|
140
|
+
aliases: ["spinalhdl", "spinal"],
|
|
141
|
+
standards: `Core rules:
|
|
142
|
+
- Component hierarchy: one Component per module. Use in()/out() for port directions. Bundle for grouped signals.
|
|
143
|
+
- ClockDomain handling: explicit clock domains with ClockDomain(). Use ClockDomainTag for multi-clock designs. BufferCC for clock domain crossing.
|
|
144
|
+
- Stream interface for handshake (valid/ready/payload): use .queue(), .m2sPipe(), .s2mPipe() for buffering. Flow for valid-only (no backpressure).
|
|
145
|
+
- Reg() for registers with init(). RegNext/RegNextWhen for convenience. Use switch/is for FSMs.
|
|
146
|
+
- Simulation: SimConfig for test setup. fork/sleep/waitUntil for testbench timing. Use SpinalSimTester for regression.
|
|
147
|
+
Pitfalls: latches from incomplete when/otherwise. Use default() assignment before conditional logic. Mind simulation delta cycles vs real hardware timing.
|
|
148
|
+
Performance: use pipeline building blocks from lib. Explicit retiming with KeepAttribute. Memory blackboxing for BRAM inference.
|
|
149
|
+
Safety: generate VHDL/Verilog and verify with formal tools. Use SpinalHDL's built-in assertion framework for hardware assertions.`,
|
|
150
|
+
});
|
|
151
|
+
// ═══════════════════════════════════════════════════════════════
|
|
152
|
+
// 3. EMBEDDED & RTOS
|
|
153
|
+
// ═══════════════════════════════════════════════════════════════
|
|
154
|
+
register({
|
|
155
|
+
name: "Embedded C",
|
|
156
|
+
category: "embedded",
|
|
157
|
+
aliases: ["embedded-c", "embedded_c", "mcu-c"],
|
|
158
|
+
standards: `Core rules:
|
|
159
|
+
- ISR rules: keep ISRs short (set flag, return). No malloc/printf/floating-point in ISR. Use volatile for ISR-shared variables. Disable/enable interrupts for critical sections.
|
|
160
|
+
- DMA safety: ensure buffer alignment. Use memory barriers before/after DMA transfers. Invalidate cache for DMA-written memory.
|
|
161
|
+
- Peripheral register access: use bit manipulation (|=, &= ~, ^=) with defined masks. Read-modify-write needs interrupt protection. Use volatile pointer casts for MMIO.
|
|
162
|
+
- Power management: enter low-power modes when idle. Disable unused peripherals' clocks. Use WFI/WFE instructions.
|
|
163
|
+
- Watchdog: configure early, kick regularly. Don't kick in ISR (masks main loop hangs). Use windowed watchdog if available.
|
|
164
|
+
Pitfalls: stack overflow in tasks/ISR — size conservatively, use canaries. Pointer alignment for ARM Cortex-M (unaligned access faults on some cores).
|
|
165
|
+
Performance: DMA for bulk transfers. Lookup tables over runtime computation. Interrupt coalescing for high-frequency events.
|
|
166
|
+
Safety: MISRA-C compliance for automotive/medical. Static analysis mandatory. Defensive programming: check all peripheral status before use.`,
|
|
167
|
+
});
|
|
168
|
+
register({
|
|
169
|
+
name: "Arduino",
|
|
170
|
+
category: "embedded",
|
|
171
|
+
aliases: ["arduino", "esp32", "esp8266", "platformio"],
|
|
172
|
+
standards: `Core rules:
|
|
173
|
+
- setup() for one-time initialization, loop() for main execution. Never block loop() with long delays.
|
|
174
|
+
- millis() over delay() for non-blocking timing. Use state machines for multi-step sequences. Track previousMillis for intervals.
|
|
175
|
+
- ISR-safe variables: declare volatile for shared variables. Use ATOMIC_BLOCK or noInterrupts()/interrupts() for multi-byte reads.
|
|
176
|
+
- PROGMEM for constant strings/arrays to save RAM: const char str[] PROGMEM. Read with pgm_read_byte/word.
|
|
177
|
+
- WiFi/BLE: reconnect logic with exponential backoff. Watchdog timer for network hangs. Secure connections (TLS/encrypted).
|
|
178
|
+
Pitfalls: String class fragments heap — use char arrays and snprintf. Don't use delay() in libraries. analogRead() on ESP32 is noisy — use averaging.
|
|
179
|
+
Performance: minimize Serial.print in production. Use hardware timers over software timing. Direct port manipulation for speed-critical GPIO.
|
|
180
|
+
Safety: input validation on all serial/network data. OTA updates with checksum verification. Brownout detection and graceful shutdown.`,
|
|
181
|
+
});
|
|
182
|
+
register({
|
|
183
|
+
name: "FreeRTOS",
|
|
184
|
+
category: "embedded",
|
|
185
|
+
aliases: ["freertos", "rtos"],
|
|
186
|
+
standards: `Core rules:
|
|
187
|
+
- Task priorities: assign based on urgency, not importance. Avoid priority inversion — use priority inheritance mutexes. Keep ISR-triggered tasks at high priority.
|
|
188
|
+
- Mutex vs semaphore: mutex for resource ownership (has owner, supports inheritance), binary semaphore for signaling (no owner). Never use mutex in ISR.
|
|
189
|
+
- Queue usage: xQueueSend for task-to-task communication. xQueueSendFromISR in ISR (with pxHigherPriorityTaskWoken). Size queues to handle burst traffic.
|
|
190
|
+
- Stack overflow detection: enable configCHECK_FOR_STACK_OVERFLOW=2. Size stacks with uxTaskGetStackHighWaterMark(). Add 20% safety margin.
|
|
191
|
+
- ISR-safe API: always use FromISR variants in ISR context (xSemaphoreGiveFromISR, xQueueSendFromISR). Pass and check pxHigherPriorityTaskWoken, call portYIELD_FROM_ISR.
|
|
192
|
+
Pitfalls: deadlock from nested mutex acquisition — always lock in consistent order. Don't call vTaskDelay in ISR. Heap fragmentation — use static allocation where possible.
|
|
193
|
+
Performance: minimize critical sections. Use task notifications (faster than semaphores) for simple signaling. Stream/message buffers for ISR-to-task data.
|
|
194
|
+
Safety: configASSERT for development. Idle hook for watchdog kicks. Stack canaries for overflow detection.`,
|
|
195
|
+
});
|
|
196
|
+
register({
|
|
197
|
+
name: "Zephyr RTOS",
|
|
198
|
+
category: "embedded",
|
|
199
|
+
aliases: ["zephyr", "zephyr-rtos"],
|
|
200
|
+
standards: `Core rules:
|
|
201
|
+
- Devicetree bindings: define hardware in .dts/.dtsi overlay files. Use DT_NODELABEL, DT_ALIAS macros to reference nodes. DEVICE_DT_GET for driver instances.
|
|
202
|
+
- Kconfig options: CONFIG_ prefix for all build options. Use menuconfig for interactive config. Dependent options with depends on/select.
|
|
203
|
+
- Kernel objects: k_thread for threads, k_sem/k_mutex for sync, k_msgq for message passing, k_timer for periodic events. All objects require initialization.
|
|
204
|
+
- Power management API: pm_device_runtime_get/put for device power. Automatic idle entry. Configure with CONFIG_PM.
|
|
205
|
+
- Logging: use LOG_MODULE_REGISTER for per-module logging. LOG_DBG/INF/WRN/ERR macros. Runtime log level filtering.
|
|
206
|
+
Pitfalls: thread stack size in Kconfig/overlay — too small causes silent corruption. Mind ISR vs thread context for API calls. Devicetree property access must match binding type.
|
|
207
|
+
Performance: use zero-copy APIs (net_buf, ring_buffer). Hardware offload where available. Minimize ISR-to-thread latency with direct ISR-to-thread notification.
|
|
208
|
+
Safety: use Zephyr's built-in security subsystem. MPU-based thread isolation. Certified for IEC 61508 (SIL3).`,
|
|
209
|
+
});
|
|
210
|
+
// ═══════════════════════════════════════════════════════════════
|
|
211
|
+
// 4. FPGA & DIGITAL DESIGN
|
|
212
|
+
// ═══════════════════════════════════════════════════════════════
|
|
213
|
+
register({
|
|
214
|
+
name: "HLS",
|
|
215
|
+
category: "fpga",
|
|
216
|
+
aliases: ["hls", "vivado-hls", "vitis-hls", "high-level-synthesis"],
|
|
217
|
+
standards: `Core rules:
|
|
218
|
+
- Pragma directives: #pragma HLS PIPELINE II=1 for throughput. #pragma HLS UNROLL for loop parallelism. #pragma HLS ARRAY_PARTITION for parallel memory access.
|
|
219
|
+
- Interface synthesis: #pragma HLS INTERFACE for port protocols. Use AXI4-Lite for control registers, AXI4-Stream for data streams, FIFO for producer-consumer.
|
|
220
|
+
- Latency vs throughput: pipeline for throughput, unroll for latency. Use DATAFLOW pragma for task-level parallelism between functions.
|
|
221
|
+
- Fixed-point arithmetic: ap_fixed<W,I> over float. Define bit-widths to match precision requirements. Use ap_int<N> for arbitrary-width integers.
|
|
222
|
+
- Loop optimization: merge nested loops when possible. Trip count hints with #pragma HLS LOOP_TRIPCOUNT. Avoid variable-bound loops.
|
|
223
|
+
Pitfalls: dynamic memory allocation not synthesizable. Recursion not supported. System calls (printf) only for simulation. Pointer arithmetic limitations.
|
|
224
|
+
Performance: minimize II (Initiation Interval). Partition arrays to resolve port contention. Use burst access for DDR. Balance pipeline stages.
|
|
225
|
+
Safety: verify with C/RTL co-simulation. Check resource utilization (LUT, FF, BRAM, DSP) against device limits. Timing closure at target frequency.`,
|
|
226
|
+
});
|
|
227
|
+
register({
|
|
228
|
+
name: "Tcl",
|
|
229
|
+
category: "fpga",
|
|
230
|
+
aliases: ["tcl", "vivado-tcl", "quartus-tcl"],
|
|
231
|
+
standards: `Core rules:
|
|
232
|
+
- Timing constraints: create_clock for all clock sources with accurate period. set_false_path for truly asynchronous paths. set_multicycle_path for multi-cycle operations.
|
|
233
|
+
- Proper quoting: curly braces {} for literal strings (no substitution), double quotes "" for substitution. Use list for building command arguments safely.
|
|
234
|
+
- Vivado/Quartus scripting: source scripts for reproducibility. Use project mode for interactive, non-project for CI. Store constraints in .xdc/.sdc files.
|
|
235
|
+
- Variable handling: set for assignment, $ for reference. Use upvar for pass-by-reference. namespace for encapsulation.
|
|
236
|
+
- Error handling: catch for error recovery. Always check return codes from tool commands. Use -quiet flag sparingly (masks real errors).
|
|
237
|
+
Pitfalls: whitespace sensitivity in Tcl — extra spaces change command parsing. Unquoted brackets trigger command substitution. Glob patterns need proper escaping.
|
|
238
|
+
Performance: batch mode over GUI for CI. Incremental compilation where supported. Parallel synthesis/implementation with -jobs flag.
|
|
239
|
+
Safety: version-control all constraint files. Review timing reports — never ignore unconstrained paths. Validate I/O constraints match schematic.`,
|
|
240
|
+
});
|
|
241
|
+
// ═══════════════════════════════════════════════════════════════
|
|
242
|
+
// 5. WEB FRONTEND
|
|
243
|
+
// ═══════════════════════════════════════════════════════════════
|
|
244
|
+
register({
|
|
245
|
+
name: "TypeScript",
|
|
246
|
+
category: "web-frontend",
|
|
247
|
+
aliases: ["ts", "typescript", "tsx"],
|
|
248
|
+
standards: `Core rules:
|
|
249
|
+
- Strict mode always (strict: true in tsconfig). Explicit return types on exported functions. No any — use unknown + type guards or generics.
|
|
250
|
+
- Prefer const over let, never var. Use readonly for immutable properties. Prefer interfaces for object shapes, type aliases for unions/intersections.
|
|
251
|
+
- Named exports over default exports. Discriminated unions for state modeling. Exhaustive switch with never for completeness checking.
|
|
252
|
+
- Null safety: optional chaining (?.) and nullish coalescing (??). Strict null checks enabled. No non-null assertions (!) unless provably safe.
|
|
253
|
+
- Error handling: custom Error subclasses with cause chain. Async functions always try-catch. Never swallow errors silently.
|
|
254
|
+
Pitfalls: avoid enums (use const objects + typeof for tree-shaking). Don't over-type — let inference work for local variables. Beware index signature pitfalls.
|
|
255
|
+
Performance: use satisfies for validation without widening. Prefer template literal types for string manipulation. Use import type for type-only imports.
|
|
256
|
+
Safety: enable strict tsconfig options (noUncheckedIndexedAccess, exactOptionalPropertyTypes). Validate external data at boundaries with runtime checks.`,
|
|
257
|
+
});
|
|
258
|
+
register({
|
|
259
|
+
name: "JavaScript",
|
|
260
|
+
category: "web-frontend",
|
|
261
|
+
aliases: ["js", "javascript", "jsx", "mjs", "cjs"],
|
|
262
|
+
standards: `Core rules:
|
|
263
|
+
- ES2022+: const by default, let when needed, never var. Optional chaining (?.) and nullish coalescing (??) for null safety.
|
|
264
|
+
- Structured clone for deep copy (structuredClone). Promise.allSettled for parallel independent operations. Array methods (map, filter, reduce) over for loops.
|
|
265
|
+
- Arrow functions for callbacks, named function declarations for top-level (hoisting + better stack traces). Destructuring for clean parameter handling.
|
|
266
|
+
- Error handling: wrap async calls in try-catch. Custom Error classes. Never swallow errors. Use cause property for error chains.
|
|
267
|
+
- Modules: ESM (import/export) over CommonJS (require). Dynamic import() for code splitting.
|
|
268
|
+
Pitfalls: === over == always. typeof null === 'object' trap. Floating point: use Math.round/toFixed for currency. Avoid prototype pollution.
|
|
269
|
+
Performance: avoid creating objects in hot loops. Use Map/Set for frequent lookups. Lazy evaluation with generators for large datasets.
|
|
270
|
+
Safety: validate and sanitize all user input. No eval() or new Function(). Use Object.freeze for constants. CSP headers for XSS protection.`,
|
|
271
|
+
});
|
|
272
|
+
register({
|
|
273
|
+
name: "React",
|
|
274
|
+
category: "web-frontend",
|
|
275
|
+
aliases: ["react", "reactjs"],
|
|
276
|
+
standards: `Core rules:
|
|
277
|
+
- Functional components only. Follow Rules of Hooks: top-level only, React functions only. Custom hooks for reusable logic (useXxx naming).
|
|
278
|
+
- Unique key props in lists (not array index unless static). React.memo() for expensive renders. useMemo/useCallback for stable references passed as props.
|
|
279
|
+
- Clean up effects: return cleanup function from useEffect. Dependency arrays must be complete (eslint-plugin-react-hooks).
|
|
280
|
+
- Avoid prop drilling: use context for truly global state, composition for intermediate cases. Co-locate state close to where it's used.
|
|
281
|
+
- Server components (Next.js 13+): server by default, 'use client' only for interactivity. Minimize client bundle. Streaming with Suspense boundaries.
|
|
282
|
+
Pitfalls: don't setState in render. Avoid object/array literals in JSX props (creates new reference each render). useEffect for sync, not for derived state.
|
|
283
|
+
Performance: React.lazy + Suspense for code splitting. Virtualize long lists (react-window). Avoid unnecessary re-renders with React DevTools profiler.
|
|
284
|
+
Safety: never dangerouslySetInnerHTML with user input. Sanitize URLs (javascript: protocol). Use Content-Security-Policy headers.`,
|
|
285
|
+
});
|
|
286
|
+
register({
|
|
287
|
+
name: "Vue",
|
|
288
|
+
category: "web-frontend",
|
|
289
|
+
aliases: ["vue", "vuejs", "vue3"],
|
|
290
|
+
standards: `Core rules:
|
|
291
|
+
- Composition API with <script setup> (Vue 3). Define props with defineProps<T>(), emits with defineEmits<T>().
|
|
292
|
+
- ref() for primitives, reactive() for objects. Access ref values with .value in script, auto-unwrapped in template.
|
|
293
|
+
- computed() for derived state (cached, reactive). watch/watchEffect for side effects. Avoid watchers when computed suffices.
|
|
294
|
+
- provide/inject for dependency injection down component tree. Use InjectionKey<T> for type safety.
|
|
295
|
+
- SFC structure: <script setup>, <template>, <style scoped>. One component per file. Composables in use*.ts files.
|
|
296
|
+
Pitfalls: don't destructure reactive() — loses reactivity. Use toRefs() instead. shallowRef for large objects that replace wholesale.
|
|
297
|
+
Performance: v-once for static content. v-memo for list optimization. defineAsyncComponent for lazy loading.
|
|
298
|
+
Safety: never use v-html with user content. Use CSP headers. Validate props with runtime validators.`,
|
|
299
|
+
});
|
|
300
|
+
register({
|
|
301
|
+
name: "Svelte",
|
|
302
|
+
category: "web-frontend",
|
|
303
|
+
aliases: ["svelte", "sveltejs", "sveltekit"],
|
|
304
|
+
standards: `Core rules:
|
|
305
|
+
- Reactive declarations with $: for derived values. Reactive statements run when dependencies change. Use $: {} blocks for side effects.
|
|
306
|
+
- Stores for shared state: writable for read/write, readable for read-only, derived for computed. Auto-subscribe with $ prefix in components.
|
|
307
|
+
- bind:value for two-way binding. on:event for event handling. Transitions with transition:, in:, out: directives.
|
|
308
|
+
- SvelteKit: load functions for data fetching (server-side). +page.ts for universal load, +page.server.ts for server-only. Form actions for mutations.
|
|
309
|
+
- Component composition: slots for content projection. $$props for spreading. Context API with setContext/getContext.
|
|
310
|
+
Pitfalls: reactivity only triggers on assignment (push/splice don't trigger — reassign array). Don't mutate store values without set/update.
|
|
311
|
+
Performance: {#key} for forcing re-creation. Lazy loading with dynamic imports. Minimal runtime overhead (Svelte compiles away the framework).
|
|
312
|
+
Safety: {@html} is dangerous — sanitize first. Use SvelteKit's CSRF protection. Validate form data server-side.`,
|
|
313
|
+
});
|
|
314
|
+
register({
|
|
315
|
+
name: "Angular",
|
|
316
|
+
category: "web-frontend",
|
|
317
|
+
aliases: ["angular", "ng"],
|
|
318
|
+
standards: `Core rules:
|
|
319
|
+
- Standalone components (no NgModule). Use signals for reactive state (signal, computed, effect). inject() for dependency injection.
|
|
320
|
+
- OnPush change detection for performance. Avoid default change detection in production components.
|
|
321
|
+
- Typed reactive forms with FormBuilder. FormControl<T> for type safety. Custom validators as pure functions.
|
|
322
|
+
- Lazy-load routes with loadComponent/loadChildren. Use resolvers for data prefetching. Guards for auth/permissions.
|
|
323
|
+
- RxJS: prefer signals over observables for state. Use async pipe in templates for subscription management. unsubscribe in ngOnDestroy or use takeUntilDestroyed.
|
|
324
|
+
Pitfalls: memory leaks from unmanaged subscriptions. Don't subscribe in constructors. Avoid circular dependency injection.
|
|
325
|
+
Performance: trackBy for *ngFor. Defer blocks (@defer) for lazy rendering. SSR with Angular Universal for initial load.
|
|
326
|
+
Safety: Angular auto-sanitizes templates. Don't bypass with bypassSecurityTrust* unless absolutely necessary. Use HttpInterceptors for auth tokens.`,
|
|
327
|
+
});
|
|
328
|
+
register({
|
|
329
|
+
name: "HTML/CSS",
|
|
330
|
+
category: "web-frontend",
|
|
331
|
+
aliases: ["html", "css", "scss", "sass", "less", "html-css"],
|
|
332
|
+
standards: `Core rules:
|
|
333
|
+
- Semantic HTML: use <article>, <section>, <nav>, <aside>, <header>, <footer>, <main>. Not div soup. Headings in order (h1>h2>h3).
|
|
334
|
+
- BEM naming for CSS classes: block__element--modifier. Or use utility-first (Tailwind) consistently. Never mix methodologies.
|
|
335
|
+
- CSS custom properties (--color-primary) for theming. Container queries (@container) for component-responsive design. Logical properties (inline/block) for i18n.
|
|
336
|
+
- Accessibility: ARIA roles/labels for custom widgets. Alt text on images. Focus management for modals/dialogs. Color contrast ratio ≥4.5:1.
|
|
337
|
+
- Modern layout: CSS Grid for 2D, Flexbox for 1D. Avoid float for layout. Use gap instead of margin hacks.
|
|
338
|
+
Pitfalls: don't nest selectors >3 levels deep. Avoid !important (specificity wars). Test in multiple browsers/viewports.
|
|
339
|
+
Performance: critical CSS inlined. Lazy-load below-fold images (loading="lazy"). Minimize layout shifts (CLS) with explicit dimensions.
|
|
340
|
+
Safety: sanitize user-generated HTML. CSP headers to block inline scripts. Use rel="noopener" on external links.`,
|
|
341
|
+
});
|
|
342
|
+
register({
|
|
343
|
+
name: "HTMX",
|
|
344
|
+
category: "web-frontend",
|
|
345
|
+
aliases: ["htmx"],
|
|
346
|
+
standards: `Core rules:
|
|
347
|
+
- hx-get/post/put/delete for HTTP methods. Server returns HTML fragments, not JSON. Progressive enhancement — works without JS as base.
|
|
348
|
+
- hx-target for specifying where to place response. Use CSS selectors. hx-swap for controlling how: innerHTML, outerHTML, beforeend, afterbegin.
|
|
349
|
+
- hx-trigger for custom event triggers. Use modifiers: changed, delay:500ms, throttle:1s. hx-trigger="load" for initial fetch.
|
|
350
|
+
- Boost links and forms with hx-boost="true" for SPA-like navigation without JavaScript.
|
|
351
|
+
- hx-indicator for loading states. hx-confirm for confirmation dialogs. hx-vals for extra values.
|
|
352
|
+
Pitfalls: don't return full page for fragment requests (check HX-Request header). Cache busting with hx-push-url. Mind CORS for cross-origin requests.
|
|
353
|
+
Performance: return minimal HTML fragments. Use 286 status code to stop polling. OOB swaps (hx-swap-oob) for updating multiple elements from one response.
|
|
354
|
+
Safety: CSRF tokens in forms. Validate HX-Request header server-side. Never trust hx-vals for authorization — validate server-side.`,
|
|
355
|
+
});
|
|
356
|
+
// ═══════════════════════════════════════════════════════════════
|
|
357
|
+
// 6. WEB BACKEND
|
|
358
|
+
// ═══════════════════════════════════════════════════════════════
|
|
359
|
+
register({
|
|
360
|
+
name: "Node.js",
|
|
361
|
+
category: "web-backend",
|
|
362
|
+
aliases: ["nodejs", "node"],
|
|
363
|
+
standards: `Core rules:
|
|
364
|
+
- Async/await everywhere. No callback-style code. Use try-catch in async functions. Handle unhandled rejections: process.on('unhandledRejection').
|
|
365
|
+
- Error handling: process.on('uncaughtException') for logging + graceful exit. Custom error classes. Never throw strings.
|
|
366
|
+
- Streams for large data (readable.pipe(writable)). Backpressure handling with highWaterMark. Use pipeline() from stream/promises.
|
|
367
|
+
- Worker threads for CPU-bound tasks. Cluster module or PM2 for multi-core. Event loop: never block with sync I/O or heavy computation.
|
|
368
|
+
- Graceful shutdown: listen for SIGTERM/SIGINT, stop accepting connections, drain existing requests, close DB pools, then exit.
|
|
369
|
+
Pitfalls: memory leaks from event listeners (setMaxListeners). Buffer handling — don't trust content length. Prototype pollution via object merge.
|
|
370
|
+
Performance: connection pooling for DB/HTTP. Use AbortController for request cancellation. Cache with LRU. JSON.parse in try-catch.
|
|
371
|
+
Safety: helmet for HTTP headers. Rate limiting. Input validation (zod/joi). No eval/Function constructor. Keep dependencies updated.`,
|
|
372
|
+
});
|
|
373
|
+
register({
|
|
374
|
+
name: "Python",
|
|
375
|
+
category: "web-backend",
|
|
376
|
+
aliases: ["py", "python", "python3"],
|
|
377
|
+
standards: `Core rules:
|
|
378
|
+
- Type hints on all function signatures (params + return type). Use from __future__ import annotations for forward refs. mypy strict mode.
|
|
379
|
+
- f-strings for formatting. pathlib.Path over os.path. enum for fixed choice sets. dataclasses or Pydantic for structured data.
|
|
380
|
+
- Context managers (with statement) for resource management: files, connections, locks. Create custom ones with @contextmanager.
|
|
381
|
+
- Async/await with asyncio for I/O-bound operations. Use asyncio.gather for parallel I/O. aiohttp/httpx for async HTTP.
|
|
382
|
+
- Exception handling: catch specific exceptions. Never bare except. Use raise ... from ... for exception chaining.
|
|
383
|
+
Pitfalls: mutable default arguments (def f(x=[])). Late binding closures in loops. Global state makes testing hard. Import cycles.
|
|
384
|
+
Performance: list comprehensions over map/filter. Generator expressions for large sequences. Use slots in classes for memory. C extensions or numpy for computation.
|
|
385
|
+
Safety: never eval() user input. Use parameterized queries. Sanitize file paths. bandit for security linting. secrets module for random tokens.`,
|
|
386
|
+
});
|
|
387
|
+
register({
|
|
388
|
+
name: "Go",
|
|
389
|
+
category: "web-backend",
|
|
390
|
+
aliases: ["go", "golang"],
|
|
391
|
+
standards: `Core rules:
|
|
392
|
+
- Handle every error explicitly. if err != nil { return ..., err }. Never use _ for errors unless documented why. Wrap errors with fmt.Errorf("context: %w", err).
|
|
393
|
+
- defer for cleanup (close files, unlock mutexes, rollback transactions). Defers run LIFO. Don't defer in loops — accumulates.
|
|
394
|
+
- Goroutine safety: channels for communication, sync.Mutex for shared state. Prefer channels. Use sync.WaitGroup for goroutine coordination. Always handle goroutine lifecycle.
|
|
395
|
+
- Interfaces: small (1-3 methods). Accept interfaces, return structs. Interface compliance: var _ Interface = (*Struct)(nil).
|
|
396
|
+
- context.Context: pass as first parameter. Use for cancellation, timeouts, and request-scoped values. Check ctx.Err() in long operations.
|
|
397
|
+
Pitfalls: goroutine leaks — always ensure goroutines can exit. Nil pointer dereference. Slice append gotcha (may or may not copy). Race detector: go test -race.
|
|
398
|
+
Performance: sync.Pool for frequent allocations. strings.Builder for concatenation. Benchmark with testing.B. Profile with pprof.
|
|
399
|
+
Safety: input validation at boundaries. Use crypto/rand not math/rand for security. Constant-time comparison for secrets.`,
|
|
400
|
+
});
|
|
401
|
+
register({
|
|
402
|
+
name: "Java",
|
|
403
|
+
category: "web-backend",
|
|
404
|
+
aliases: ["java"],
|
|
405
|
+
standards: `Core rules:
|
|
406
|
+
- Records for data carriers (immutable by design). Sealed interfaces/classes for sum types. Pattern matching in switch (Java 21+).
|
|
407
|
+
- Optional<T> for return types that may be absent. Never pass null as argument. Never call .get() without .isPresent() — use .orElse/.map/.ifPresent.
|
|
408
|
+
- Try-with-resources for all AutoCloseable. Specific catch blocks. Multi-catch (catch (A | B e)) for shared handling.
|
|
409
|
+
- var for local variables when RHS makes type obvious. Streams API for collection transformations. Collectors for terminal operations.
|
|
410
|
+
- Virtual threads (Java 21+) for I/O-bound concurrency. CompletableFuture for async composition. Structured concurrency for task scoping.
|
|
411
|
+
Pitfalls: equals/hashCode contract — override both or neither. Immutability: defensive copies of mutable fields. ConcurrentModificationException from iterating+modifying.
|
|
412
|
+
Performance: StringBuilder for loops. Parallel streams only for CPU-bound work on large collections. JMH for benchmarks. Avoid autoboxing in hot paths.
|
|
413
|
+
Safety: input validation with Bean Validation. Prepared statements for SQL. No reflection on untrusted input. Secure deserialization.`,
|
|
414
|
+
});
|
|
415
|
+
register({
|
|
416
|
+
name: "Kotlin",
|
|
417
|
+
category: "web-backend",
|
|
418
|
+
aliases: ["kt", "kotlin", "kts"],
|
|
419
|
+
standards: `Core rules:
|
|
420
|
+
- data class for value types (auto equals/hashCode/copy/toString). sealed class/interface for exhaustive when expressions.
|
|
421
|
+
- Null safety: nullable types (T?) are explicit. Use ?. (safe call), ?: (elvis), let for null checks. Avoid !! (force unwrap) — use requireNotNull with message.
|
|
422
|
+
- Coroutines with suspend functions. Use structured concurrency (CoroutineScope). Flow for reactive streams. Never use GlobalScope in production.
|
|
423
|
+
- Extension functions for adding behavior without inheritance. Scope functions: let for null check + transform, apply for builder pattern, use for AutoCloseable.
|
|
424
|
+
- Kotlin-specific: prefer val over var. when is exhaustive for sealed types. Destructuring declarations. Delegation with by keyword.
|
|
425
|
+
Pitfalls: data class with mutable properties defeats purpose. Coroutine cancellation — check isActive or use ensureActive(). Kotlin/JVM interop: @JvmStatic, @JvmField.
|
|
426
|
+
Performance: inline functions for lambdas in hot paths. Sequence for lazy collection processing. value class for zero-overhead wrappers.
|
|
427
|
+
Safety: use Kotlin's type system to prevent invalid states. require/check for preconditions. @Throws for Java interop.`,
|
|
428
|
+
});
|
|
429
|
+
register({
|
|
430
|
+
name: "C#",
|
|
431
|
+
category: "web-backend",
|
|
432
|
+
aliases: ["cs", "csharp", "c#", "dotnet"],
|
|
433
|
+
standards: `Core rules:
|
|
434
|
+
- Nullable reference types enabled (#nullable enable). Annotate all APIs with nullability. Fix all nullable warnings.
|
|
435
|
+
- Records for immutable data types. record struct for value semantics. Init-only setters (init) for controlled initialization.
|
|
436
|
+
- Pattern matching: switch expressions, is pattern, relational/logical patterns. Use discard (_) for don't-care cases.
|
|
437
|
+
- async/await for all I/O operations. Use ValueTask for hot paths that often complete synchronously. CancellationToken propagation.
|
|
438
|
+
- LINQ for collection queries. Use method syntax for complex queries. Avoid LINQ in hot loops (allocation overhead). Span<T>/Memory<T> for zero-copy slicing.
|
|
439
|
+
Pitfalls: async void only for event handlers. Dispose pattern for unmanaged resources. ConfigureAwait(false) in library code.
|
|
440
|
+
Performance: ArrayPool/MemoryPool for buffer reuse. struct for small, frequently-allocated types. Benchmark with BenchmarkDotNet.
|
|
441
|
+
Safety: validate model binding. Parameterized queries via EF Core or Dapper. Use IDataProtector for encryption. Anti-forgery tokens for forms.`,
|
|
442
|
+
});
|
|
443
|
+
register({
|
|
444
|
+
name: "Ruby",
|
|
445
|
+
category: "web-backend",
|
|
446
|
+
aliases: ["rb", "ruby"],
|
|
447
|
+
standards: `Core rules:
|
|
448
|
+
- frozen_string_literal: true at file top for immutable strings (performance + safety). Use dup/+'' when mutation needed.
|
|
449
|
+
- Keyword arguments for optional params with defaults. Use **options sparingly. Blocks/procs/lambdas: blocks for iteration, procs for stored callbacks, lambdas for strict arity.
|
|
450
|
+
- Modules over deep inheritance hierarchies. Include for instance methods, extend for class methods. Composition with Forwardable.
|
|
451
|
+
- RBS type signatures (.rbs files) or Sorbet annotations for type checking. steep check in CI. Document public API types.
|
|
452
|
+
- Convention: snake_case methods/variables, CamelCase classes, SCREAMING_SNAKE for constants. Predicate methods end with ?. Bang methods (!) for mutation.
|
|
453
|
+
Pitfalls: nil is an object (NoMethodError, not NullPointerException). Hash default value shared reference trap. Monkey-patching breaks encapsulation.
|
|
454
|
+
Performance: freeze constant strings. Use each over map when discarding result. Symbol vs String for identifiers. Benchmark with benchmark-ips.
|
|
455
|
+
Safety: Brakeman for Rails security scanning. Parameterize SQL. Strong parameters in Rails. CSRF protection enabled by default.`,
|
|
456
|
+
});
|
|
457
|
+
register({
|
|
458
|
+
name: "PHP",
|
|
459
|
+
category: "web-backend",
|
|
460
|
+
aliases: ["php"],
|
|
461
|
+
standards: `Core rules:
|
|
462
|
+
- declare(strict_types=1) at file top. Type declarations on all function params and returns. Union types (string|int) for flexibility.
|
|
463
|
+
- Named arguments for readability: fn(timeout: 30, retries: 3). Enums (PHP 8.1+) for fixed choice sets. Match expression over switch for value returns.
|
|
464
|
+
- Readonly properties (readonly) and readonly classes for immutability. Constructor property promotion for concise DTOs.
|
|
465
|
+
- Fibers for cooperative concurrency. Use for async I/O frameworks (Swoole, ReactPHP, Amp).
|
|
466
|
+
- Null safety: ?-> (nullsafe operator), ?? (null coalesce), Nullable types (?Type). Never return mixed without documentation.
|
|
467
|
+
Pitfalls: loose comparison (==) quirks — use === always. Array key existence: array_key_exists vs isset (null values). Memory leaks in long-running processes.
|
|
468
|
+
Performance: OPcache enabled with preloading. JIT for CPU-bound tasks (PHP 8.0+). Avoid autoloading in hot paths.
|
|
469
|
+
Safety: prepared statements (PDO::prepare). htmlspecialchars for output. CSRF tokens. password_hash/password_verify for passwords. Never trust $_GET/$_POST directly.`,
|
|
470
|
+
});
|
|
471
|
+
register({
|
|
472
|
+
name: "Elixir",
|
|
473
|
+
category: "web-backend",
|
|
474
|
+
aliases: ["ex", "exs", "elixir"],
|
|
475
|
+
standards: `Core rules:
|
|
476
|
+
- Pattern matching everywhere: function heads, case, with. Multi-clause functions ordered specific → general. Guards for type checks.
|
|
477
|
+
- Pipe operator (|>) for data transformation chains. Left-to-right reading. First argument is piped value.
|
|
478
|
+
- GenServer for stateful processes. Supervision trees for fault tolerance (one_for_one, rest_for_one). Let it crash — supervisors restart.
|
|
479
|
+
- Protocols for polymorphism (like interfaces). Behaviours for contracts. Use @impl true for clarity.
|
|
480
|
+
- ExUnit for testing. describe/test structure. Use setup for shared context. async: true for concurrent tests. Doctests for examples.
|
|
481
|
+
Pitfalls: large binaries in process mailbox cause GC issues. Don't store state in module attributes at runtime. Avoid GenServer bottleneck (single mailbox).
|
|
482
|
+
Performance: binary pattern matching for parsing. ETS for shared read-heavy state. Stream for lazy enumeration. NIF for CPU-bound (with care).
|
|
483
|
+
Safety: Phoenix CSRF protection. Parameterized queries with Ecto. Input validation with Ecto changesets. Secrets in runtime config, not compile time.`,
|
|
484
|
+
});
|
|
485
|
+
register({
|
|
486
|
+
name: "Scala",
|
|
487
|
+
category: "web-backend",
|
|
488
|
+
aliases: ["scala", "sc"],
|
|
489
|
+
standards: `Core rules:
|
|
490
|
+
- Case classes for immutable data (auto equals/hashCode/copy/unapply). Sealed traits for algebraic data types with exhaustive pattern matching.
|
|
491
|
+
- For-comprehensions for monadic composition (Option, Future, Either, IO). Use yield for generating values.
|
|
492
|
+
- Scala 3: given/using over implicit. Extension methods over implicit classes. Opaque types for zero-cost wrappers. Union/intersection types.
|
|
493
|
+
- Cats Effect / ZIO for functional effect systems. IO monad for side effects. Resource for safe acquisition/release. Fiber for structured concurrency.
|
|
494
|
+
- Pattern matching: match expressions with guards. Extractors (unapply) for custom patterns. Variable patterns with backticks for constants.
|
|
495
|
+
Pitfalls: Future is eager (starts immediately) — use IO/Task for lazy evaluation. Avoid Any/Nothing leaking into APIs. Implicit resolution can be opaque — use given/using.
|
|
496
|
+
Performance: use LazyList (not Stream which is deprecated). Tail recursion with @tailrec. Avoid boxing with @specialized or opaque types.
|
|
497
|
+
Safety: type-level guarantees reduce runtime errors. Use refined types for validated data. Never catch Throwable (catches fatal errors).`,
|
|
498
|
+
});
|
|
499
|
+
// ═══════════════════════════════════════════════════════════════
|
|
500
|
+
// 7. MOBILE
|
|
501
|
+
// ═══════════════════════════════════════════════════════════════
|
|
502
|
+
register({
|
|
503
|
+
name: "Swift",
|
|
504
|
+
category: "mobile",
|
|
505
|
+
aliases: ["swift"],
|
|
506
|
+
standards: `Core rules:
|
|
507
|
+
- Value types: prefer struct over class. Classes only for identity, inheritance, or reference semantics. Use enum for fixed state sets.
|
|
508
|
+
- Protocol-oriented programming: define behavior with protocols. Use protocol extensions for default implementations. Prefer composition over inheritance.
|
|
509
|
+
- Concurrency: async/await for asynchronous code. Actors for shared mutable state. Sendable protocol for thread-safe types. Task groups for structured concurrency.
|
|
510
|
+
- SwiftUI: State, Binding, ObservedObject, EnvironmentObject for data flow. View structs are lightweight — recreated frequently. Use @ViewBuilder for composition.
|
|
511
|
+
- Optionals: guard let for early exit. if let for conditional binding. Never force-unwrap (!) outside tests. Use nil coalescing (??) for defaults.
|
|
512
|
+
Pitfalls: retain cycles with closures — use [weak self] or [unowned self]. SwiftUI body recomputation — keep it pure. MainActor for UI updates.
|
|
513
|
+
Performance: avoid AnyView (erases type info, prevents diff optimization). Lazy stacks (LazyVStack/LazyHStack) for long lists. Profile with Instruments.
|
|
514
|
+
Safety: App Transport Security for HTTPS. Keychain for sensitive data. Use CryptoKit for cryptographic operations.`,
|
|
515
|
+
});
|
|
516
|
+
register({
|
|
517
|
+
name: "Kotlin Android",
|
|
518
|
+
category: "mobile",
|
|
519
|
+
aliases: ["kotlin-android", "android", "jetpack-compose"],
|
|
520
|
+
standards: `Core rules:
|
|
521
|
+
- Jetpack Compose: composable functions with @Composable. State hoisting (state up, events down). remember + mutableStateOf for local state.
|
|
522
|
+
- ViewModel + StateFlow for UI state. Collect with collectAsStateWithLifecycle(). Single source of truth for state.
|
|
523
|
+
- Hilt for dependency injection: @HiltViewModel, @Inject constructor. Modules with @Provides/@Binds. Scoping: @Singleton, @ViewModelScoped.
|
|
524
|
+
- Coroutines: viewModelScope for ViewModel operations. lifecycleScope for Activity/Fragment. Dispatchers.IO for I/O, Main for UI.
|
|
525
|
+
- Room DAO: @Entity, @Dao, @Query. Flow return type for reactive queries. Suspend functions for writes. Migration strategy defined.
|
|
526
|
+
Pitfalls: recomposition performance — avoid lambdas creating new instances. derivedStateOf for expensive computations. key() in LazyColumn for stable items.
|
|
527
|
+
Performance: baseline profiles for startup. R8/ProGuard for release builds. Avoid unnecessary recomposition (stable types, immutable data).
|
|
528
|
+
Safety: ProGuard rules for reflection-based libraries. Encrypted SharedPreferences for sensitive data. Certificate pinning for network.`,
|
|
529
|
+
});
|
|
530
|
+
register({
|
|
531
|
+
name: "Dart",
|
|
532
|
+
category: "mobile",
|
|
533
|
+
aliases: ["dart", "flutter"],
|
|
534
|
+
standards: `Core rules:
|
|
535
|
+
- final for variables set once, const for compile-time constants. Use late for lazy initialization. Null safety: T? for nullable, ! only when proven safe.
|
|
536
|
+
- Async: Future for single values, Stream for sequences. async* for generator functions. Use await for sequential, Future.wait for parallel.
|
|
537
|
+
- State management: Riverpod for production apps (typed, testable, tree-shakable). Bloc for event-driven architectures. Provider as simple alternative.
|
|
538
|
+
- Widget composition: small, focused widgets. Prefer StatelessWidget. Extract sub-widgets for reuse and performance. Use const constructors.
|
|
539
|
+
- Platform channels for native code: MethodChannel for calls, EventChannel for streams. Use Pigeon for type-safe platform communication.
|
|
540
|
+
Pitfalls: setState causes full widget rebuild — use state management for complex state. Avoid deep widget nesting — extract widgets. BuildContext usage after async gaps.
|
|
541
|
+
Performance: const constructors prevent unnecessary rebuilds. RepaintBoundary for isolated repaints. ListView.builder for long lists (lazy).
|
|
542
|
+
Safety: secure storage (flutter_secure_storage). Certificate pinning. Obfuscate release builds (--obfuscate). Don't hardcode API keys.`,
|
|
543
|
+
});
|
|
544
|
+
register({
|
|
545
|
+
name: "React Native",
|
|
546
|
+
category: "mobile",
|
|
547
|
+
aliases: ["react-native", "rn"],
|
|
548
|
+
standards: `Core rules:
|
|
549
|
+
- FlatList for lists (not ScrollView — ScrollView renders all items). Use keyExtractor, getItemLayout for performance. SectionList for grouped data.
|
|
550
|
+
- Native modules: use TurboModules (new architecture) for native bridge. Fabric for custom native views. Codegen for type-safe native interfaces.
|
|
551
|
+
- Hermes engine: enabled by default. Supports bytecode precompilation. JSON.parse is optimized — use for large data. No eval() support.
|
|
552
|
+
- Reanimated for animations: worklets run on UI thread. useSharedValue for animated values. useAnimatedStyle for style interpolation.
|
|
553
|
+
- Gesture handling: react-native-gesture-handler for performant gestures. Gesture.Pan/Tap/LongPress composable. GestureDetector wrapping.
|
|
554
|
+
Pitfalls: bridge serialization overhead — minimize cross-bridge calls. Don't pass complex objects. Inline requires for startup performance.
|
|
555
|
+
Performance: use memo/useCallback for list items. InteractionManager for post-animation work. Avoid large images without caching (FastImage).
|
|
556
|
+
Safety: secure storage for tokens (react-native-keychain). Certificate pinning. No sensitive data in AsyncStorage (unencrypted).`,
|
|
557
|
+
});
|
|
558
|
+
// ═══════════════════════════════════════════════════════════════
|
|
559
|
+
// 8. DATA & ML
|
|
560
|
+
// ═══════════════════════════════════════════════════════════════
|
|
561
|
+
register({
|
|
562
|
+
name: "Python ML",
|
|
563
|
+
category: "data-ml",
|
|
564
|
+
aliases: ["python-ml", "ml", "pytorch", "tensorflow", "numpy", "pandas"],
|
|
565
|
+
standards: `Core rules:
|
|
566
|
+
- NumPy vectorization: no Python loops over arrays. Use broadcasting, fancy indexing, einsum for batch operations. Shape comments on complex ops.
|
|
567
|
+
- Pandas method chaining: df.pipe().assign().query().groupby(). No iterrows() — use vectorized operations or apply() as last resort.
|
|
568
|
+
- scikit-learn pipeline: Pipeline/ColumnTransformer for reproducible preprocessing. Train/test split before any preprocessing. Cross-validation for evaluation.
|
|
569
|
+
- PyTorch: torch.no_grad() for inference. Gradient checkpointing for large models. Mixed precision (torch.cuda.amp) for training speed.
|
|
570
|
+
- Reproducibility: set seeds (random, numpy, torch, CUDA). Pin dependency versions. Log hyperparameters. Version control data with DVC.
|
|
571
|
+
Pitfalls: data leakage (fitting on test data). SettingWithCopyWarning in Pandas — use .loc[]. GPU memory leaks from detached tensors. NaN propagation.
|
|
572
|
+
Performance: GPU-CPU transfer is expensive — batch operations on GPU. Use DataLoader with num_workers>0. Prefetch data.
|
|
573
|
+
Safety: validate input data shape and type before model. Sanitize user-provided model paths. Don't pickle untrusted data.`,
|
|
574
|
+
});
|
|
575
|
+
register({
|
|
576
|
+
name: "R",
|
|
577
|
+
category: "data-ml",
|
|
578
|
+
aliases: ["r", "rlang"],
|
|
579
|
+
standards: `Core rules:
|
|
580
|
+
- Tidyverse: use tibbles over data.frames. Pipe operator (|> or %>%) for readable chains. dplyr verbs: mutate, filter, select, summarize, group_by.
|
|
581
|
+
- ggplot2 layers: aes() for mapping, geom_ for geometry, scale_ for axes, theme_ for styling. Facets for multi-panel plots.
|
|
582
|
+
- purrr::map family for iteration: map for list, map_dbl for double, map_dfr for row-binding. Avoid for loops for data operations.
|
|
583
|
+
- Reproducible reports: R Markdown (.Rmd) or Quarto (.qmd). Set seeds (set.seed). Use renv for dependency management.
|
|
584
|
+
- Functions: explicit return() or last expression. Use roxygen2 for documentation (@param, @return, @examples).
|
|
585
|
+
Pitfalls: R is 1-indexed. Factor vs character confusion. Recycling rule silently extends short vectors. Partial matching in $ operator.
|
|
586
|
+
Performance: vectorize operations. data.table for large datasets. Avoid growing vectors in loops (preallocate). Use Rcpp for C++ hot paths.
|
|
587
|
+
Safety: don't source() untrusted R scripts. Validate file paths. Use parameterized queries for DB access. Sanitize Shiny inputs.`,
|
|
588
|
+
});
|
|
589
|
+
register({
|
|
590
|
+
name: "SQL",
|
|
591
|
+
category: "data-ml",
|
|
592
|
+
aliases: ["sql", "postgresql", "postgres", "mysql", "sqlite", "mssql"],
|
|
593
|
+
standards: `Core rules:
|
|
594
|
+
- PARAMETERIZED QUERIES ALWAYS. Never concatenate user input into SQL strings. Use $1/$2 (Postgres), ? (MySQL), @param (MSSQL), or ORM parameterization.
|
|
595
|
+
- CTEs (WITH) over nested subqueries for readability and reuse. Window functions (ROW_NUMBER, RANK, LAG, LEAD) over self-joins for analytics.
|
|
596
|
+
- Proper indexing: columns in WHERE, JOIN ON, ORDER BY. Composite indexes: leftmost prefix rule. Don't over-index (write overhead). EXPLAIN ANALYZE to verify.
|
|
597
|
+
- Transaction isolation: READ COMMITTED default. Use SERIALIZABLE for critical consistency. Keep transactions short. Handle deadlocks with retry logic.
|
|
598
|
+
- SELECT only needed columns (not *). Use EXISTS over IN for correlated subqueries. COALESCE for null handling.
|
|
599
|
+
Pitfalls: implicit type conversions break index usage. NULL in comparisons (use IS NULL/IS NOT NULL). ORDER BY without LIMIT on large tables. N+1 query problem.
|
|
600
|
+
Performance: batch inserts over single-row. Use COPY (Postgres) for bulk loading. Materialized views for expensive aggregations. Partial indexes for filtered queries.
|
|
601
|
+
Safety: least privilege (GRANT specific permissions). Row-level security for multi-tenant. Audit logging for sensitive tables. Encrypted connections (SSL).`,
|
|
602
|
+
});
|
|
603
|
+
register({
|
|
604
|
+
name: "Julia",
|
|
605
|
+
category: "data-ml",
|
|
606
|
+
aliases: ["jl", "julia"],
|
|
607
|
+
standards: `Core rules:
|
|
608
|
+
- Type stability: functions should return consistent types. Use @code_warntype to check. Avoid containers with abstract element types (Vector{Any}).
|
|
609
|
+
- Multiple dispatch: define methods for specific type combinations. Use abstract types for hierarchy. Parametric types for generic containers.
|
|
610
|
+
- Broadcasting with dot syntax: f.(x) applies elementwise. Use @. macro for fusing multiple broadcasts. Avoids temporary allocations.
|
|
611
|
+
- Avoid global variables in performance-critical code (type instability). Use const for global constants. Pass data as function arguments.
|
|
612
|
+
- Package development: use Pkg.develop for local packages. Precompilation with __init__() for setup. SnoopPrecompile for reducing load time.
|
|
613
|
+
Pitfalls: 1-indexed arrays. First-call latency (compilation). Column-major storage (iterate columns first). String indexing is byte-based (use eachindex).
|
|
614
|
+
Performance: preallocate output arrays. Use @inbounds in inner loops (after correctness verification). StaticArrays for small fixed-size arrays.
|
|
615
|
+
Safety: input validation at public API boundaries. Don't eval untrusted strings. Use Sandbox.jl for untrusted code execution.`,
|
|
616
|
+
});
|
|
617
|
+
// ═══════════════════════════════════════════════════════════════
|
|
618
|
+
// 9. DEVOPS & INFRASTRUCTURE
|
|
619
|
+
// ═══════════════════════════════════════════════════════════════
|
|
620
|
+
register({
|
|
621
|
+
name: "Bash",
|
|
622
|
+
category: "devops",
|
|
623
|
+
aliases: ["sh", "bash", "shell", "zsh"],
|
|
624
|
+
standards: `Core rules:
|
|
625
|
+
- set -euo pipefail at script top. -e exits on error, -u on undefined variable, -o pipefail catches pipe failures.
|
|
626
|
+
- ShellCheck compliance: run shellcheck on all scripts. Fix all warnings. SC2086 (quote variables) is critical.
|
|
627
|
+
- Quote all variable expansions: "$var", "$@", "$(command)". Unquoted variables cause word splitting and globbing bugs.
|
|
628
|
+
- trap for cleanup: trap cleanup EXIT. Clean up temp files, kill background processes, restore state.
|
|
629
|
+
- Functions over inline scripts. Local variables with local keyword. Return values via stdout (capture with $()) or return code.
|
|
630
|
+
Pitfalls: [ vs [[ — use [[ for bash (pattern matching, no word splitting). Don't parse ls output — use globs. No spaces around = in assignment.
|
|
631
|
+
Performance: avoid subshells in loops ($(command) forks). Use bash builtins over external commands. Process substitution (<()) over temp files.
|
|
632
|
+
Safety: never use eval with user input. Validate all external inputs. Use mktemp for temp files. Set restrictive umask (077) for sensitive files.`,
|
|
633
|
+
});
|
|
634
|
+
register({
|
|
635
|
+
name: "PowerShell",
|
|
636
|
+
category: "devops",
|
|
637
|
+
aliases: ["ps1", "powershell", "pwsh"],
|
|
638
|
+
standards: `Core rules:
|
|
639
|
+
- Approved verbs: Get-, Set-, New-, Remove-, Invoke-, etc. Use Get-Verb to list. Follow Verb-Noun naming for cmdlets.
|
|
640
|
+
- Pipeline: pipe objects (not text). Use Where-Object, ForEach-Object, Select-Object for filtering/transformation. Pipeline input via process block.
|
|
641
|
+
- Error handling: try/catch/finally for terminating errors. Use -ErrorAction Stop to make non-terminating errors catchable. $ErrorActionPreference = 'Stop' in scripts.
|
|
642
|
+
- PSScriptAnalyzer: run for lint checking. Fix all warnings. Use [CmdletBinding()] for advanced function features (Verbose, Debug, WhatIf).
|
|
643
|
+
- Parameter validation: [ValidateNotNullOrEmpty()], [ValidateSet()], [ValidateRange()]. Use mandatory parameters with [Parameter(Mandatory)].
|
|
644
|
+
Pitfalls: single-element arrays unwrap automatically (use @()). Comparison operators are case-insensitive by default (-ceq for case-sensitive). Pipeline unrolls arrays.
|
|
645
|
+
Performance: avoid Write-Host for output (use Write-Output). StringBuilder for string concatenation. Filter left, format right. Avoid Where-Object on large collections — use .Where() method.
|
|
646
|
+
Safety: execution policy doesn't prevent malicious scripts. Use -Credential for remote operations. SecureString for passwords. Sign scripts in production.`,
|
|
647
|
+
});
|
|
648
|
+
register({
|
|
649
|
+
name: "Dockerfile",
|
|
650
|
+
category: "devops",
|
|
651
|
+
aliases: ["dockerfile", "docker", "containerfile"],
|
|
652
|
+
standards: `Core rules:
|
|
653
|
+
- Multi-stage builds: separate build and runtime stages. Copy only artifacts to final stage. Minimize final image size.
|
|
654
|
+
- .dockerignore: exclude .git, node_modules, build artifacts, secrets. Keep context small for fast builds.
|
|
655
|
+
- Non-root user: RUN adduser/useradd + USER directive. Never run production containers as root.
|
|
656
|
+
- COPY over ADD (ADD has implicit tar extraction and URL fetch — unexpected behavior). Use --chown with COPY.
|
|
657
|
+
- Layer caching: order from least to most frequently changing. Dependencies before source code. Use --mount=type=cache for package managers.
|
|
658
|
+
Pitfalls: each RUN creates a layer — chain with && and \ for related commands. Don't store secrets in layers (use BuildKit secrets). Pin base image versions.
|
|
659
|
+
Performance: use slim/alpine base images. Health checks with HEALTHCHECK. Minimize layers. Use BuildKit parallel builds.
|
|
660
|
+
Safety: scan images with trivy/grype. No secrets in ENV or ARG. Use read-only filesystem (--read-only). Drop capabilities (--cap-drop ALL).`,
|
|
661
|
+
});
|
|
662
|
+
register({
|
|
663
|
+
name: "Terraform",
|
|
664
|
+
category: "devops",
|
|
665
|
+
aliases: ["tf", "terraform", "hcl", "opentofu"],
|
|
666
|
+
standards: `Core rules:
|
|
667
|
+
- Modules for reusable infrastructure. Keep modules focused (one resource group per module). Use versioned module sources.
|
|
668
|
+
- State management: remote backend (S3+DynamoDB, GCS, Azure Blob). State locking enabled. Never edit state manually. Use terraform state mv for refactoring.
|
|
669
|
+
- Variables: validation blocks for constraints. Use type constraints. sensitive = true for secrets. Default values where sensible.
|
|
670
|
+
- Lifecycle blocks: prevent_destroy for critical resources. create_before_destroy for zero-downtime. ignore_changes for externally managed attributes.
|
|
671
|
+
- Data sources over hardcoding: data.aws_ami, data.aws_vpc for dynamic references. Locals for computed values.
|
|
672
|
+
Pitfalls: terraform plan doesn't catch all issues (IAM, quotas). Circular dependencies. Provider version constraints required. State drift detection.
|
|
673
|
+
Performance: targeted applies (-target) for large stacks. Parallelism tuning (-parallelism). Module composition over monolithic configs.
|
|
674
|
+
Safety: checkov/tfsec for security scanning. No secrets in .tf files (use vault or environment variables). Least privilege IAM. Enable access logging.`,
|
|
675
|
+
});
|
|
676
|
+
register({
|
|
677
|
+
name: "Kubernetes",
|
|
678
|
+
category: "devops",
|
|
679
|
+
aliases: ["k8s", "kubernetes", "kubectl", "helm"],
|
|
680
|
+
standards: `Core rules:
|
|
681
|
+
- Resource limits: always set requests and limits for CPU/memory. Requests for scheduling, limits for enforcement. Use LimitRange for defaults.
|
|
682
|
+
- Health probes: livenessProbe (restart on failure), readinessProbe (remove from service), startupProbe (slow-starting apps). Configure appropriate intervals and thresholds.
|
|
683
|
+
- Security context: runAsNonRoot: true, readOnlyRootFilesystem: true, allowPrivilegeEscalation: false. Drop all capabilities, add only needed.
|
|
684
|
+
- Pod disruption budgets: minAvailable or maxUnavailable for high availability during rolling updates/node drains.
|
|
685
|
+
- Labels/selectors: consistent labeling (app, version, environment, team). Use label selectors for service routing and policy targeting.
|
|
686
|
+
Pitfalls: don't use :latest tag (non-deterministic). imagePullPolicy: Always wastes bandwidth. Resource limits too tight cause OOMKill. Graceful shutdown with preStop hook.
|
|
687
|
+
Performance: horizontal pod autoscaler (HPA) with custom metrics. Topology spread constraints for even distribution. Resource right-sizing with VPA recommendations.
|
|
688
|
+
Safety: NetworkPolicy for pod-to-pod isolation. RBAC with least privilege. Pod Security Standards (restricted). Secrets encrypted at rest. No hostPath volumes in production.`,
|
|
689
|
+
});
|
|
690
|
+
register({
|
|
691
|
+
name: "Ansible",
|
|
692
|
+
category: "devops",
|
|
693
|
+
aliases: ["ansible", "ansible-playbook"],
|
|
694
|
+
standards: `Core rules:
|
|
695
|
+
- Idempotency: all tasks must be safe to run multiple times. Use state: present/absent, not shell commands. Check mode (--check) support.
|
|
696
|
+
- Handlers for service restarts: notify on change, handlers run once at end. Use listen for multiple triggers.
|
|
697
|
+
- Roles for reusable automation: defaults/vars/tasks/handlers/templates/files structure. Galaxy for sharing. Requirements.yml for dependencies.
|
|
698
|
+
- Vault for secrets: ansible-vault encrypt_string for inline. Vault files for bulk secrets. Never commit plaintext secrets.
|
|
699
|
+
- Molecule for testing: create/converge/verify/destroy cycle. Use testinfra or goss for verification. CI/CD integration.
|
|
700
|
+
Pitfalls: YAML gotchas (yes/no as booleans, colon in strings). Variable precedence is complex (extra vars > role vars > inventory). Jinja2 whitespace control.
|
|
701
|
+
Performance: use async for long-running tasks. Forks for parallel execution. Fact caching for repeated runs. Mitogen strategy for speed.
|
|
702
|
+
Safety: become: yes only when needed. Limit playbook scope with --limit. No shell/command modules for tasks that have dedicated modules. Audit changes with --diff.`,
|
|
703
|
+
});
|
|
704
|
+
register({
|
|
705
|
+
name: "Nix",
|
|
706
|
+
category: "devops",
|
|
707
|
+
aliases: ["nix", "nixos", "nixpkgs"],
|
|
708
|
+
standards: `Core rules:
|
|
709
|
+
- Pure functions: every derivation is a function of its inputs. No side effects. Fixed-output derivations for network access only.
|
|
710
|
+
- Flakes for reproducibility: flake.nix with inputs/outputs. Lock file (flake.lock) pins all dependencies. Use nix develop for dev shells.
|
|
711
|
+
- Overlays for package modifications: final: prev: pattern. Use overlays for patching, version bumps, or adding packages. Composable and ordered.
|
|
712
|
+
- nixpkgs patterns: mkDerivation for packages. buildInputs vs nativeBuildInputs (cross-compilation). Phases: unpackPhase, buildPhase, installPhase.
|
|
713
|
+
- Development shells: use devShells in flake.nix. Include all build dependencies. Use direnv with use flake for auto-activation.
|
|
714
|
+
Pitfalls: infinite recursion from circular overlays. String interpolation evaluates eagerly. Large closures waste disk space — use nix-store --gc.
|
|
715
|
+
Performance: binary caches (cachix) for pre-built packages. Minimize closure size with removeReferencesTo. Use nix-diff to compare derivations.
|
|
716
|
+
Safety: sandboxed builds by default (no network, restricted filesystem). Verify hashes for fetchurl. NixOS: declarative system configuration, atomic upgrades and rollbacks.`,
|
|
717
|
+
});
|
|
718
|
+
// ═══════════════════════════════════════════════════════════════
|
|
719
|
+
// 10. SCRIPTING & AUTOMATION
|
|
720
|
+
// ═══════════════════════════════════════════════════════════════
|
|
721
|
+
register({
|
|
722
|
+
name: "Lua",
|
|
723
|
+
category: "scripting",
|
|
724
|
+
aliases: ["lua", "luajit"],
|
|
725
|
+
standards: `Core rules:
|
|
726
|
+
- Always use local: local x = 1. Global variables pollute the environment and are slower. Use module pattern for encapsulation.
|
|
727
|
+
- Metatables for OOP: __index for inheritance, __newindex for proxy, __tostring for display. Keep metatable chains shallow.
|
|
728
|
+
- Coroutines for cooperative multitasking: coroutine.create/resume/yield. Use for generators, state machines, async patterns.
|
|
729
|
+
- Tables are the single data structure: arrays (1-indexed), dictionaries, objects. Use # operator for array length (caveat: holes).
|
|
730
|
+
- LuaJIT FFI for C interop: ffi.cdef for declarations, ffi.new for allocation. Zero-overhead C function calls.
|
|
731
|
+
Pitfalls: table length with holes is undefined. nil in tables creates holes. 1-based indexing. String comparison is by value, table comparison by reference.
|
|
732
|
+
Performance: LuaJIT: avoid NYI (not-yet-implemented) operations in traces. Localize frequently used functions (local insert = table.insert). Avoid table creation in hot loops.
|
|
733
|
+
Safety: sandbox untrusted scripts by removing dangerous functions (os, io, loadfile). Use setfenv/debug.setfenv (Lua 5.1) or _ENV (5.2+) for sandboxing.`,
|
|
734
|
+
});
|
|
735
|
+
register({
|
|
736
|
+
name: "Perl",
|
|
737
|
+
category: "scripting",
|
|
738
|
+
aliases: ["pl", "perl", "pm"],
|
|
739
|
+
standards: `Core rules:
|
|
740
|
+
- use strict; use warnings; at top of every file. Use Modern::Perl or feature bundles for modern syntax. use utf8 for Unicode source.
|
|
741
|
+
- References for complex data: \\@array, \\%hash, \\&sub. Dereference with ->. Use data structures (AoH, HoA) for structured data.
|
|
742
|
+
- Regex mastery: named captures (?<name>), /x for readable patterns, qr// for compiled regex. Non-greedy (.*?) by default thinking.
|
|
743
|
+
- OOP: use Moose/Moo for modern OO. has for attributes, with for roles. Type constraints. BUILD/BUILDARGS for initialization.
|
|
744
|
+
- CPAN module structure: use Dist::Zilla or ExtUtils::MakeMaker. Tests in t/. POD documentation. Semantic versioning.
|
|
745
|
+
Pitfalls: list vs scalar context changes behavior. Implicit $_ can be confusing. Autovivification creates structure unexpectedly. Regex greediness.
|
|
746
|
+
Performance: avoid regex compilation in loops (use qr//). Benchmark with Benchmark or Dumbbench. Use XS for hot inner loops.
|
|
747
|
+
Safety: taint mode (-T) for CGI/input handling. Validate all user input. Use DBI with placeholders for SQL. No eval on untrusted input.`,
|
|
748
|
+
});
|
|
749
|
+
register({
|
|
750
|
+
name: "AWK",
|
|
751
|
+
category: "scripting",
|
|
752
|
+
aliases: ["awk", "gawk", "mawk"],
|
|
753
|
+
standards: `Core rules:
|
|
754
|
+
- Pattern-action paradigm: /pattern/ { action }. Each line is processed automatically. Use BEGIN for initialization, END for summary.
|
|
755
|
+
- Field separator: -F for command-line, FS variable in BEGIN block. OFS for output field separator. Split with split(string, array, separator).
|
|
756
|
+
- Associative arrays: array[key] = value. Use (key in array) to test existence. delete array[key]. for (key in array) for iteration (unordered).
|
|
757
|
+
- Built-in variables: NR (record number), NF (number of fields), $0 (whole line), $1-$NF (fields). FILENAME, FNR (file record number).
|
|
758
|
+
- Printf for formatted output: printf "%s\\t%d\\n", $1, $2. Use sprintf for string formatting.
|
|
759
|
+
Pitfalls: uninitialized variables are "" or 0 (not errors). String vs number comparison depends on context. Regex with / / not " ". Field assignment rebuilds $0.
|
|
760
|
+
Performance: avoid external commands (system/getline pipe) in tight loops. Pre-compile regex with match(). Mawk is fastest for simple tasks.
|
|
761
|
+
Safety: don't process untrusted input without field validation. Escape shell metacharacters in system() calls. Use getline carefully (can return -1 on error).`,
|
|
762
|
+
});
|
|
763
|
+
register({
|
|
764
|
+
name: "Makefile",
|
|
765
|
+
category: "scripting",
|
|
766
|
+
aliases: ["makefile", "make", "gnumake"],
|
|
767
|
+
standards: `Core rules:
|
|
768
|
+
- .PHONY targets for non-file targets: .PHONY: all clean test build. Prevents conflicts with same-named files.
|
|
769
|
+
- Automatic variables: $@ (target), $< (first prerequisite), $^ (all prerequisites), $* (stem in pattern rules). Use consistently.
|
|
770
|
+
- Pattern rules: %.o: %.c for generic build rules. Static pattern rules for specific subsets. Use $< for the source file.
|
|
771
|
+
- Order-only prerequisites (| delimiter): directories that must exist but don't trigger rebuild. target: normal | order-only.
|
|
772
|
+
- Variable assignment: := (immediate), = (recursive), ?= (conditional), += (append). Use := for computed values to avoid re-evaluation.
|
|
773
|
+
Pitfalls: recipes use shell (not make) syntax. Each line is a separate shell — use \\ for multi-line or .ONESHELL. Tabs required (not spaces) for recipes.
|
|
774
|
+
Performance: parallel builds with -j N. Proper dependency tracking (auto-generate with -MMD -MP). Avoid recursive make (use include instead).
|
|
775
|
+
Safety: validate inputs in recipes. Use $(shell) sparingly. Set SHELL := /bin/bash explicitly if using bash features. Don't ignore errors (prefix with - only when intentional).`,
|
|
776
|
+
});
|
|
777
|
+
// ═══════════════════════════════════════════════════════════════
|
|
778
|
+
// 11. FUNCTIONAL LANGUAGES
|
|
779
|
+
// ═══════════════════════════════════════════════════════════════
|
|
780
|
+
register({
|
|
781
|
+
name: "Haskell",
|
|
782
|
+
category: "functional",
|
|
783
|
+
aliases: ["hs", "haskell"],
|
|
784
|
+
standards: `Core rules:
|
|
785
|
+
- Pure functions by default. IO monad for side effects — isolate at program edges. Use do-notation for monadic composition.
|
|
786
|
+
- Type classes: define behavior contracts. Derive common instances (Show, Eq, Ord, Read). Newtypes for type-safe wrappers with zero runtime cost.
|
|
787
|
+
- Maybe for optional values (Just/Nothing), Either for error handling (Left error/Right value). Never use error/undefined in library code.
|
|
788
|
+
- Lazy evaluation: be aware of thunk accumulation. Use seq/BangPatterns/StrictData for performance-critical data. -Wall -Werror in CI.
|
|
789
|
+
- Pattern matching: exhaustive matches (-Wincomplete-patterns). Use guards for complex conditions. As-patterns (x@(Cons _ _)) for binding and destructuring.
|
|
790
|
+
Pitfalls: space leaks from laziness (unevaluated thunks). String is [Char] (slow) — use Text or ByteString. Orphan instances break coherence.
|
|
791
|
+
Performance: Text over String. Vector over List for random access. Strict fields in data types (!) for known-evaluated data. Profile with +RTS -s.
|
|
792
|
+
Safety: use Safe Haskell for untrusted code. Type-level programming for static guarantees. QuickCheck for property-based testing.`,
|
|
793
|
+
});
|
|
794
|
+
register({
|
|
795
|
+
name: "OCaml",
|
|
796
|
+
category: "functional",
|
|
797
|
+
aliases: ["ml", "ocaml"],
|
|
798
|
+
standards: `Core rules:
|
|
799
|
+
- Pattern matching: exhaustive match/with. Compiler warns on incomplete patterns — never disable. Use _ for wildcard, as for binding.
|
|
800
|
+
- Modules/functors: module signatures (.mli) define interfaces. Functors for parameterized modules. First-class modules for runtime abstraction.
|
|
801
|
+
- Immutable by default: use ref only when necessary. List/Map for persistent data structures. Array/Hashtbl for mutable when performance requires.
|
|
802
|
+
- GADTs for type-safe DSLs and embedded languages. Polymorphic variants for extensible types. Type annotations for clarity at module boundaries.
|
|
803
|
+
- Dune build system: dune-project for project config. Libraries with (library) stanza. Inline tests with ppx_inline_test.
|
|
804
|
+
Pitfalls: value restriction for polymorphic mutable values. Structural vs nominal typing for objects vs records. Tail recursion — use @tail_mod_cons or List.rev.
|
|
805
|
+
Performance: flambda optimization pass (-O2). Use Bigarray for numerical work. Avoid excessive allocation in inner loops. Benchmark with core_bench.
|
|
806
|
+
Safety: type system prevents most runtime errors. Use Result.t for recoverable errors. Alcotest for testing. OCaml 5: effects for structured concurrency.`,
|
|
807
|
+
});
|
|
808
|
+
register({
|
|
809
|
+
name: "F#",
|
|
810
|
+
category: "functional",
|
|
811
|
+
aliases: ["fs", "fsharp", "f#"],
|
|
812
|
+
standards: `Core rules:
|
|
813
|
+
- Computation expressions: async { }, task { }, seq { }, result { } for monadic workflows. Custom builders for domain-specific control flow.
|
|
814
|
+
- Active patterns: (|Pattern|_|) for reusable pattern matching. Partial active patterns for parsing/validation. Parameterized active patterns.
|
|
815
|
+
- Type providers: compile-time types from external schemas (JSON, SQL, CSV). Use for strongly-typed data access without code generation.
|
|
816
|
+
- Discriminated unions for algebraic data types: type Shape = Circle of float | Rectangle of float * float. Exhaustive matching enforced.
|
|
817
|
+
- Pipe operator (|>) for left-to-right data flow. Function composition (>>) for point-free style. Partial application for factory functions.
|
|
818
|
+
Pitfalls: indentation-based scoping — whitespace sensitive. Equality is structural for records/unions, referential for classes. Mutable variables need <- not =.
|
|
819
|
+
Performance: struct records/unions for stack allocation. Span<T> for zero-allocation slicing. Tail calls with rec keyword. Inline for generic numerical code.
|
|
820
|
+
Safety: Fable for F#-to-JavaScript compilation. Use Result<'T,'E> over exceptions. Expecto for testing. Type-safe API with Giraffe/Saturn.`,
|
|
821
|
+
});
|
|
822
|
+
register({
|
|
823
|
+
name: "Clojure",
|
|
824
|
+
category: "functional",
|
|
825
|
+
aliases: ["clj", "cljs", "clojure", "clojurescript"],
|
|
826
|
+
standards: `Core rules:
|
|
827
|
+
- Immutable data by default: maps {}, vectors [], sets #{}, lists (). Persistent data structures (structural sharing). Use assoc/update/dissoc for transformation.
|
|
828
|
+
- Protocols for polymorphism: defprotocol + extend-protocol/extend-type. Like interfaces but extensible to existing types. Multimethods for flexible dispatch.
|
|
829
|
+
- Transducers for composable transformations: (comp (map f) (filter g)) — no intermediate collections. Use with transduce, into, sequence.
|
|
830
|
+
- Spec for data validation: s/def, s/fdef for function specs. s/valid? for checking. Generative testing with spec + test.check.
|
|
831
|
+
- REPL-driven development: evaluate forms interactively. Rich comments (comment ...) for development snippets. Develop bottom-up, compose upward.
|
|
832
|
+
Pitfalls: lazy sequences hold head in memory (don't bind to local). Nil punning (nil is falsey, empty collection is truthy). Reflection warnings indicate performance issue.
|
|
833
|
+
Performance: type hints for Java interop (^String x). Transients for local mutation in builders. Avoid reflection — use (set! *warn-on-reflection* true).
|
|
834
|
+
Safety: don't eval user input. Use clojure.edn/read-string (not read-string) for untrusted data. Component/Integrant for system lifecycle management.`,
|
|
835
|
+
});
|
|
836
|
+
// ═══════════════════════════════════════════════════════════════
|
|
837
|
+
// 12. GAME DEVELOPMENT
|
|
838
|
+
// ═══════════════════════════════════════════════════════════════
|
|
839
|
+
register({
|
|
840
|
+
name: "GDScript",
|
|
841
|
+
category: "game",
|
|
842
|
+
aliases: ["gd", "gdscript", "godot"],
|
|
843
|
+
standards: `Core rules:
|
|
844
|
+
- Signals for decoupled communication: signal my_signal(arg). Connect via code (connect) or editor. Custom signals over direct references.
|
|
845
|
+
- Node references: @onready var for deferred access. Use $ or get_node for children. Never hardcode paths to distant nodes — use groups or signals.
|
|
846
|
+
- Lifecycle: _ready() for initialization, _process(delta) for per-frame logic, _physics_process(delta) for physics. _enter_tree/_exit_tree for scene management.
|
|
847
|
+
- @export vars for inspector-exposed properties. Use @export_range, @export_enum for constrained values. Resource types for shared data.
|
|
848
|
+
- Scene composition: one script per scene root. Child scenes for reusable components. PackedScene for dynamic instantiation.
|
|
849
|
+
Pitfalls: _process runs every frame — avoid heavy computation. Use is_instance_valid before accessing freed nodes. Signal connections leak if not disconnected.
|
|
850
|
+
Performance: use Object pooling for frequent instantiation. Visibility notifiers for off-screen culling. GDExtension (C++) for hot paths.
|
|
851
|
+
Safety: validate deserialized save data. Don't trust client-side game state in multiplayer. Sanitize player names/chat input.`,
|
|
852
|
+
});
|
|
853
|
+
register({
|
|
854
|
+
name: "Unity C#",
|
|
855
|
+
category: "game",
|
|
856
|
+
aliases: ["unity", "unity-csharp", "unity-c#"],
|
|
857
|
+
standards: `Core rules:
|
|
858
|
+
- MonoBehaviour lifecycle: Awake → OnEnable → Start → Update/FixedUpdate → LateUpdate → OnDisable → OnDestroy. Never use constructors.
|
|
859
|
+
- Coroutines for time-based sequences: yield return new WaitForSeconds(). Use StopCoroutine for cleanup. Consider async/await with UniTask.
|
|
860
|
+
- ScriptableObjects for shared data assets: configuration, events, variables. Reduce scene dependencies. Reusable across scenes.
|
|
861
|
+
- Object pooling: reuse frequently spawned objects (bullets, particles, enemies). Deactivate instead of Destroy. Pool managers with Queue<T>.
|
|
862
|
+
- [SerializeField] for private fields in inspector. Never public fields without reason. Use [Header], [Tooltip], [Range] for editor UX.
|
|
863
|
+
Pitfalls: GetComponent is expensive — cache in Awake. String-based APIs (SendMessage, Find) are slow and fragile. Don't allocate in Update (GC spikes).
|
|
864
|
+
Performance: FixedUpdate rate for physics (not frame-dependent). Jobs + Burst compiler for CPU-intensive work. LOD groups for rendering.
|
|
865
|
+
Safety: validate user-generated content. Server-authoritative for multiplayer. Don't trust PlayerPrefs for security. Obfuscate builds for anti-cheat.`,
|
|
866
|
+
});
|
|
867
|
+
register({
|
|
868
|
+
name: "GLSL",
|
|
869
|
+
category: "game",
|
|
870
|
+
aliases: ["glsl", "hlsl", "shader", "shading"],
|
|
871
|
+
standards: `Core rules:
|
|
872
|
+
- Precision qualifiers: highp for position/depth, mediump for color/UV, lowp for simple masks. Mobile requires explicit precision (GLES).
|
|
873
|
+
- Uniforms for per-draw data, varying/in-out for vertex→fragment interpolation, attributes/in for per-vertex data. Minimize varying count.
|
|
874
|
+
- Avoid dynamic branching in fragment shaders (all threads in a warp diverge). Use step/mix/smoothstep for branchless selection.
|
|
875
|
+
- Texture sampling: minimize dependent texture reads. Pack data into fewer textures (channel packing). Use mipmaps to prevent aliasing.
|
|
876
|
+
- Compute shaders: shared memory for intra-workgroup data. memoryBarrierShared + barrier() for synchronization. Dispatch size = data size / workgroup size.
|
|
877
|
+
Pitfalls: integer division truncates. normalize(vec3(0)) is undefined. Floating point precision issues at large world coordinates. Driver bugs vary across vendors.
|
|
878
|
+
Performance: minimize texture fetches and register usage. Use half precision where quality allows (HLSL: half, GLSL: mediump). Batch draw calls.
|
|
879
|
+
Safety: validate shader compilation (glGetShaderiv GL_COMPILE_STATUS). Handle driver crashes gracefully. Test on minimum-spec hardware.`,
|
|
880
|
+
});
|
|
881
|
+
register({
|
|
882
|
+
name: "Unreal C++",
|
|
883
|
+
category: "game",
|
|
884
|
+
aliases: ["unreal", "ue5", "ue4", "unreal-cpp"],
|
|
885
|
+
standards: `Core rules:
|
|
886
|
+
- UPROPERTY() macro for all UObject member variables: enables GC tracking, serialization, replication, Blueprint exposure. Categories with Category="Name".
|
|
887
|
+
- UFUNCTION() for Blueprint-callable/overridable functions. BlueprintCallable, BlueprintPure, BlueprintImplementableEvent. Server/Client for RPC.
|
|
888
|
+
- Garbage collection: UObject pointers are tracked. Use UPROPERTY or TWeakObjectPtr for non-owning refs. TSharedPtr for non-UObject shared ownership.
|
|
889
|
+
- FString for mutable strings, FName for identifiers (case-insensitive, hashed), FText for localized display text. Use FString::Printf for formatting.
|
|
890
|
+
- Delegates: DECLARE_DYNAMIC_MULTICAST_DELEGATE for Blueprint-bindable events. Regular delegates for C++ only. Lambda binding with BindLambda.
|
|
891
|
+
Pitfalls: UPROPERTY(Transient) for non-serialized fields. Hard references cause memory bloat — use soft references (TSoftObjectPtr). Tick functions are expensive — disable when unused.
|
|
892
|
+
Performance: object pooling with SpawnActor/DestroyActor avoidance. Level streaming for open worlds. Nanite for geometry, Lumen for lighting (UE5).
|
|
893
|
+
Safety: validate replicated data server-side. Anti-cheat integration. Limit Blueprint execution authority. Encrypt pak files for asset protection.`,
|
|
894
|
+
});
|
|
895
|
+
// ═══════════════════════════════════════════════════════════════
|
|
896
|
+
// 13. BLOCKCHAIN & SMART CONTRACTS
|
|
897
|
+
// ═══════════════════════════════════════════════════════════════
|
|
898
|
+
register({
|
|
899
|
+
name: "Solidity",
|
|
900
|
+
category: "blockchain",
|
|
901
|
+
aliases: ["sol", "solidity"],
|
|
902
|
+
standards: `Core rules:
|
|
903
|
+
- Checks-Effects-Interactions pattern: validate inputs (require/revert), update state, then external calls. Prevents reentrancy. Use ReentrancyGuard as defense-in-depth.
|
|
904
|
+
- Gas optimization: pack storage variables (uint128+uint128 in one slot). Use calldata over memory for readonly params. Minimize storage writes (SSTORE is 20k gas).
|
|
905
|
+
- Custom errors over string reverts: error InsufficientBalance(uint256 available, uint256 required). Saves ~50 bytes per error site.
|
|
906
|
+
- Access control: OpenZeppelin Ownable/AccessControl. Role-based permissions. Timelocks for admin functions. onlyOwner/onlyRole modifiers.
|
|
907
|
+
- Events for off-chain indexing: emit Event for every state change. Indexed parameters (up to 3) for filtering. Log topic optimization.
|
|
908
|
+
Pitfalls: integer overflow (use Solidity 0.8+ built-in checks or SafeMath). Don't use tx.origin for auth (phishing). Delegatecall storage collision. Front-running.
|
|
909
|
+
Performance: batch operations over loops. Mapping over array for lookups. Immutable/constant for gas-free reads. Assembly (Yul) for micro-optimization.
|
|
910
|
+
Safety: audit before mainnet. Test with Foundry/Hardhat (fork testing). Formal verification for critical contracts. Upgradeable proxy pattern with storage gaps.`,
|
|
911
|
+
});
|
|
912
|
+
register({
|
|
913
|
+
name: "Solana Rust",
|
|
914
|
+
category: "blockchain",
|
|
915
|
+
aliases: ["solana", "solana-rust", "anchor"],
|
|
916
|
+
standards: `Core rules:
|
|
917
|
+
- Account validation: verify account owner, signer, writable status. Check discriminators. Use Anchor constraints: #[account(mut, has_one = authority)].
|
|
918
|
+
- PDA derivation: Pubkey::find_program_address with deterministic seeds. Store bump for re-derivation. Use canonical bumps. Seeds must be unique per PDA purpose.
|
|
919
|
+
- CPI safety: Cross-Program Invocations with explicit signer seeds for PDAs. Verify target program ID. Propagate errors with into() conversion.
|
|
920
|
+
- Rent exemption: accounts must hold minimum rent-exempt balance. Use SystemProgram::create_account with proper space calculation. Close accounts to reclaim rent.
|
|
921
|
+
- Anchor framework: #[program] for entrypoints, #[derive(Accounts)] for account contexts. #[account(init, payer, space)] for account creation.
|
|
922
|
+
Pitfalls: arithmetic overflow (use checked_add/mul). Account reallocation needs realloc instruction. Signer checks missing = anyone can call. Close account properly (zero data + lamports transfer).
|
|
923
|
+
Performance: minimize account lookups. Batch instructions in single transaction. Use zero-copy for large accounts. Compute budget with set_compute_unit_limit.
|
|
924
|
+
Safety: verify all account constraints. No unchecked arithmetic. Audit with Soteria/sec3. Timelock for admin instructions. Emergency pause mechanism.`,
|
|
925
|
+
});
|
|
926
|
+
register({
|
|
927
|
+
name: "Move",
|
|
928
|
+
category: "blockchain",
|
|
929
|
+
aliases: ["move", "aptos", "sui"],
|
|
930
|
+
standards: `Core rules:
|
|
931
|
+
- Resource types: struct with key/store abilities. Resources can't be copied or dropped — must be explicitly moved or destroyed. Enforces asset safety.
|
|
932
|
+
- Abilities: key (storable in global storage), store (nested in other structs), copy (copyable), drop (droppable). Minimal abilities principle.
|
|
933
|
+
- Acquires annotation: functions accessing global storage must declare acquires T. Compiler enforces — prevents dangling reference issues.
|
|
934
|
+
- Module friends: friend keyword for controlled inter-module access. public(friend) for restricted visibility. Module is the unit of encapsulation.
|
|
935
|
+
- Phantom types: phantom type parameters for type-level tags without runtime cost. Useful for Coin<CoinType> patterns.
|
|
936
|
+
Pitfalls: global storage ops (borrow_global, move_from) can abort on missing resources — check exists() first. Move's linear type system is strict — plan ownership flow.
|
|
937
|
+
Performance: minimize global storage reads/writes. Use vector for batch operations. Inline functions for small utilities.
|
|
938
|
+
Safety: formal verification with Move Prover (spec blocks). Integer overflow checked by default. Resource safety guaranteed by type system. Access control via signer parameter.`,
|
|
939
|
+
});
|
|
940
|
+
// ═══════════════════════════════════════════════════════════════
|
|
941
|
+
// 14. EMERGING & SPECIALIZED
|
|
942
|
+
// ═══════════════════════════════════════════════════════════════
|
|
943
|
+
register({
|
|
944
|
+
name: "WebAssembly",
|
|
945
|
+
category: "emerging",
|
|
946
|
+
aliases: ["wasm", "wat", "webassembly"],
|
|
947
|
+
standards: `Core rules:
|
|
948
|
+
- Linear memory: single contiguous byte array. Grow with memory.grow (page = 64KB). Bounds-checked access. Shared memory for threads (SharedArrayBuffer).
|
|
949
|
+
- Stack machine model: instructions consume/produce stack values. Type-safe — stack types verified at validation time. No undefined behavior.
|
|
950
|
+
- Import/export: import functions, memory, tables, globals from host. Export module functions for host to call. Use function indices for indirect calls.
|
|
951
|
+
- WASI for system interface: file I/O, sockets, clocks. Capability-based security. Preview 2 with component model.
|
|
952
|
+
- Component model: interfaces defined in WIT (WebAssembly Interface Type). Composable modules with type-safe boundaries.
|
|
953
|
+
Pitfalls: no GC (manage memory manually or use GC languages targeting wasm). No direct DOM access (call through JS). Integer-only (no native strings).
|
|
954
|
+
Performance: SIMD instructions for vectorized computation. Memory alignment for performance. Streaming compilation for fast startup. Use wasm-opt for optimization.
|
|
955
|
+
Safety: sandboxed execution by design. Validate all imported function arguments. Memory bounds checked by runtime. No raw pointer access to host memory.`,
|
|
956
|
+
});
|
|
957
|
+
register({
|
|
958
|
+
name: "CUDA",
|
|
959
|
+
category: "emerging",
|
|
960
|
+
aliases: ["cu", "cuda"],
|
|
961
|
+
standards: `Core rules:
|
|
962
|
+
- Grid/block/thread hierarchy: grid of blocks, block of threads. dim3 for dimensions. Thread ID: threadIdx.x + blockIdx.x * blockDim.x. Size blocks as multiples of warp (32).
|
|
963
|
+
- Shared memory (__shared__): per-block fast memory for inter-thread communication. Use for tiling, reduction, prefix sum. __syncthreads() for barrier synchronization.
|
|
964
|
+
- Coalesced memory access: adjacent threads access adjacent global memory addresses. Stride-1 pattern. Avoid bank conflicts in shared memory (padding).
|
|
965
|
+
- Synchronization: __syncthreads() within block. Atomics for inter-block (atomicAdd, atomicCAS). Cooperative groups for flexible sync patterns.
|
|
966
|
+
- Occupancy: balance threads/block, shared memory, registers for maximum SM utilization. Use CUDA occupancy calculator. Launch bounds with __launch_bounds__.
|
|
967
|
+
Pitfalls: race conditions without sync. Warp divergence (if/else) serializes threads. Host-device transfer is bottleneck — minimize and overlap with computation.
|
|
968
|
+
Performance: use streams for async execution + overlap. Pinned memory for fast H2D/D2H transfer. Tensor cores for matrix operations. Unified memory for convenience.
|
|
969
|
+
Safety: check all CUDA API calls (cudaGetLastError). Handle device OOM. Validate kernel launch parameters. nsight-compute for profiling.`,
|
|
970
|
+
});
|
|
971
|
+
register({
|
|
972
|
+
name: "OpenCL",
|
|
973
|
+
category: "emerging",
|
|
974
|
+
aliases: ["cl", "opencl"],
|
|
975
|
+
standards: `Core rules:
|
|
976
|
+
- Work-items (threads) organized in work-groups (blocks). NDRange defines global/local work sizes. Global ID: get_global_id(dim).
|
|
977
|
+
- Local memory (__local): per-work-group fast memory. Use barrier(CLK_LOCAL_MEM_FENCE) for synchronization. Explicit allocation in kernel arguments or inline.
|
|
978
|
+
- Kernel optimization: vectorize with vector types (float4, int8). Coalesced global memory access. Minimize branching divergence.
|
|
979
|
+
- Platform portability: query device capabilities (CL_DEVICE_MAX_WORK_GROUP_SIZE). Use cl_khr extensions conditionally. Test on multiple vendors (NVIDIA, AMD, Intel).
|
|
980
|
+
- Memory model: global, local, constant, private address spaces. Explicit transfers (clEnqueueReadBuffer/WriteBuffer). Map for zero-copy when available.
|
|
981
|
+
Pitfalls: work-group size must divide global size evenly (or use remainder handling). Different precision on different devices. Compiler optimization varies by vendor.
|
|
982
|
+
Performance: use image objects for 2D data (hardware-accelerated access). Persistent kernels for reducing launch overhead. Sub-buffers for partitioned data.
|
|
983
|
+
Safety: check all cl_ API return codes. Release all cl objects (clRelease*). Validate kernel arguments. Handle device disconnection gracefully.`,
|
|
984
|
+
});
|
|
985
|
+
register({
|
|
986
|
+
name: "Mojo",
|
|
987
|
+
category: "emerging",
|
|
988
|
+
aliases: ["mojo", "modular"],
|
|
989
|
+
standards: `Core rules:
|
|
990
|
+
- Python superset: full Python compatibility plus systems-level performance. Use def for Python-compatible functions, fn for strict Mojo functions.
|
|
991
|
+
- SIMD types: SIMD[DType.float32, 8] for vectorized operations. Hardware-width agnostic. Use @parameter for compile-time SIMD width selection.
|
|
992
|
+
- Ownership model: borrowed (immutable reference), inout (mutable reference), owned (transfer ownership). Similar to Rust but gradual adoption.
|
|
993
|
+
- struct vs @value decorator: struct for C-like performance types. @value auto-generates __init__, __copyinit__, __moveinit__. Use for value semantics.
|
|
994
|
+
- Compile-time metaprogramming: alias for compile-time constants. @parameter decorator for compile-time function variants. Parametric types for generic code.
|
|
995
|
+
Pitfalls: not all Python libraries available in compiled mode. Mojo structs are not Python classes (no inheritance). Memory management differs from Python GC.
|
|
996
|
+
Performance: autotune for automatic parameter optimization. Parallelize with parallelize(). Tiling for cache-friendly access patterns. Benchmark with benchmark module.
|
|
997
|
+
Safety: bounds checking enabled by default. Use DTypePointer safely. Validate external data at boundaries. Mojo's type system catches many errors at compile time.`,
|
|
998
|
+
});
|
|
999
|
+
// ═══════════════════════════════════════════════════════════════
|
|
1000
|
+
// GENERAL STANDARDS (language-agnostic)
|
|
1001
|
+
// ═══════════════════════════════════════════════════════════════
|
|
1002
|
+
const GENERAL_STANDARDS = `- DRY: Don't repeat yourself, but don't abstract prematurely either.
|
|
1003
|
+
- YAGNI: Don't build what you don't need yet.
|
|
1004
|
+
- Meaningful names: variables describe what they hold, functions describe what they do.
|
|
1005
|
+
- Small functions: each function does one thing. If it needs a comment to explain, it's too complex.
|
|
1006
|
+
- Early returns: reduce nesting by handling edge cases first.
|
|
1007
|
+
- Fail fast: validate inputs at boundaries, trust data internally.
|
|
1008
|
+
- Separation of concerns: I/O at the edges, pure logic in the core.`;
|
|
1009
|
+
// ═══════════════════════════════════════════════════════════════
|
|
1010
|
+
// FILE EXTENSION → LANGUAGE MAPPING
|
|
1011
|
+
// ═══════════════════════════════════════════════════════════════
|
|
1012
|
+
const EXT_MAP = {
|
|
1013
|
+
// Systems
|
|
1014
|
+
c: "c", h: "c",
|
|
1015
|
+
cpp: "c++", hpp: "c++", cc: "c++", cxx: "c++", hxx: "c++",
|
|
1016
|
+
rs: "rust",
|
|
1017
|
+
asm: "assembly", s: "assembly",
|
|
1018
|
+
zig: "zig",
|
|
1019
|
+
// HDL
|
|
1020
|
+
vhd: "vhdl", vhdl: "vhdl",
|
|
1021
|
+
v: "verilog", sv: "verilog",
|
|
1022
|
+
// Web frontend
|
|
1023
|
+
ts: "typescript", tsx: "typescript",
|
|
1024
|
+
js: "javascript", jsx: "javascript", mjs: "javascript", cjs: "javascript",
|
|
1025
|
+
vue: "vue", svelte: "svelte",
|
|
1026
|
+
html: "html/css", css: "html/css", scss: "html/css", sass: "html/css", less: "html/css",
|
|
1027
|
+
// Web backend
|
|
1028
|
+
py: "python", pyi: "python",
|
|
1029
|
+
go: "go",
|
|
1030
|
+
java: "java",
|
|
1031
|
+
kt: "kotlin", kts: "kotlin",
|
|
1032
|
+
cs: "c#", csx: "c#",
|
|
1033
|
+
rb: "ruby", rake: "ruby",
|
|
1034
|
+
php: "php",
|
|
1035
|
+
ex: "elixir", exs: "elixir",
|
|
1036
|
+
scala: "scala", sc: "scala",
|
|
1037
|
+
// Mobile
|
|
1038
|
+
swift: "swift",
|
|
1039
|
+
dart: "dart",
|
|
1040
|
+
// Data & ML
|
|
1041
|
+
r: "r", rmd: "r",
|
|
1042
|
+
sql: "sql",
|
|
1043
|
+
jl: "julia",
|
|
1044
|
+
// DevOps
|
|
1045
|
+
sh: "bash", bash: "bash", zsh: "bash",
|
|
1046
|
+
ps1: "powershell", psm1: "powershell", psd1: "powershell",
|
|
1047
|
+
tf: "terraform", tfvars: "terraform",
|
|
1048
|
+
nix: "nix",
|
|
1049
|
+
// Scripting
|
|
1050
|
+
lua: "lua",
|
|
1051
|
+
pl: "perl", pm: "perl",
|
|
1052
|
+
awk: "awk",
|
|
1053
|
+
// Functional
|
|
1054
|
+
hs: "haskell", lhs: "haskell",
|
|
1055
|
+
ml: "ocaml", mli: "ocaml",
|
|
1056
|
+
fs: "f#", fsi: "f#", fsx: "f#",
|
|
1057
|
+
clj: "clojure", cljs: "clojure", cljc: "clojure", edn: "clojure",
|
|
1058
|
+
// Game
|
|
1059
|
+
gd: "gdscript",
|
|
1060
|
+
glsl: "glsl", hlsl: "glsl", frag: "glsl", vert: "glsl", comp: "glsl",
|
|
1061
|
+
// Blockchain
|
|
1062
|
+
sol: "solidity",
|
|
1063
|
+
move: "move",
|
|
1064
|
+
// Emerging
|
|
1065
|
+
wat: "webassembly", wast: "webassembly",
|
|
1066
|
+
cu: "cuda", cuh: "cuda",
|
|
1067
|
+
cl: "opencl",
|
|
1068
|
+
mojo: "mojo",
|
|
1069
|
+
};
|
|
1070
|
+
// Also handle special filenames
|
|
1071
|
+
const FILENAME_MAP = {
|
|
1072
|
+
dockerfile: "dockerfile",
|
|
1073
|
+
"docker-compose.yml": "kubernetes",
|
|
1074
|
+
"docker-compose.yaml": "kubernetes",
|
|
1075
|
+
makefile: "makefile",
|
|
1076
|
+
gnumakefile: "makefile",
|
|
1077
|
+
"cmakelists.txt": "makefile",
|
|
1078
|
+
jenkinsfile: "bash",
|
|
1079
|
+
vagrantfile: "ruby",
|
|
1080
|
+
};
|
|
1081
|
+
// ═══════════════════════════════════════════════════════════════
|
|
1082
|
+
// PUBLIC API
|
|
1083
|
+
// ═══════════════════════════════════════════════════════════════
|
|
1084
|
+
/**
|
|
1085
|
+
* Get coding standards for a language.
|
|
1086
|
+
* Accepts language name or alias (case-insensitive).
|
|
1087
|
+
*/
|
|
1088
|
+
export function getCodingStandards(language) {
|
|
1089
|
+
const std = STANDARDS.get(language.toLowerCase().trim());
|
|
1090
|
+
return std?.standards ?? null;
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Get all supported language names (unique, sorted).
|
|
1094
|
+
* Backward-compatible alias for getAllLanguages.
|
|
1095
|
+
*/
|
|
1096
|
+
export function getSupportedLanguages() {
|
|
1097
|
+
return getAllLanguages();
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Get all unique language names (sorted).
|
|
1101
|
+
*/
|
|
1102
|
+
export function getAllLanguages() {
|
|
1103
|
+
const seen = new Set();
|
|
1104
|
+
for (const std of STANDARDS.values()) {
|
|
1105
|
+
seen.add(std.name);
|
|
1106
|
+
}
|
|
1107
|
+
return [...seen].sort();
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Get languages by category.
|
|
1111
|
+
*/
|
|
1112
|
+
export function getLanguagesByCategory(category) {
|
|
1113
|
+
const result = [];
|
|
1114
|
+
const seen = new Set();
|
|
1115
|
+
for (const std of STANDARDS.values()) {
|
|
1116
|
+
if (std.category === category && !seen.has(std.name)) {
|
|
1117
|
+
result.push(std.name);
|
|
1118
|
+
seen.add(std.name);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
return result.sort();
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Check if coding standards exist for a given language.
|
|
1125
|
+
*/
|
|
1126
|
+
export function hasStandards(language) {
|
|
1127
|
+
return STANDARDS.has(language.toLowerCase().trim());
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Get the general coding principles that apply to all languages.
|
|
1131
|
+
* Appended when no language-specific standards are available.
|
|
1132
|
+
*/
|
|
1133
|
+
export function getGeneralStandards() {
|
|
1134
|
+
return GENERAL_STANDARDS;
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Detect language from file path (extension or filename).
|
|
1138
|
+
* Returns the canonical language key usable with getCodingStandards().
|
|
1139
|
+
*/
|
|
1140
|
+
export function detectLanguage(filePath) {
|
|
1141
|
+
// Check special filenames first
|
|
1142
|
+
const filename = filePath.split("/").pop()?.toLowerCase() ?? "";
|
|
1143
|
+
if (FILENAME_MAP[filename]) {
|
|
1144
|
+
return FILENAME_MAP[filename];
|
|
1145
|
+
}
|
|
1146
|
+
// Check extension
|
|
1147
|
+
const ext = filename.split(".").pop()?.toLowerCase();
|
|
1148
|
+
if (!ext)
|
|
1149
|
+
return null;
|
|
1150
|
+
return EXT_MAP[ext] ?? null;
|
|
1151
|
+
}
|
|
1152
|
+
//# sourceMappingURL=coding-standards.js.map
|