ascii-chat-c-development
Skill203 starsChanged 8 days agoMITView on GitHub
Develop and debug ascii-chat's native C code across transports, media, rendering, TUIs, crypto, and WASM. Use for implementation, debugging, or review in this repository.
In this repository11 other files it gives its agents.
- web/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ascii-chat-cli-releaseSkill
- ascii-chat-cross-platform-development-and-or-testingSkill
- ascii-chat-documentationSkill
- ascii-chat-mcp-devSkill
- ascii-chat-python-developmentSkill
- ascii-chat-testingSkill
- ascii-chat-wasm-developmentSkill
- ascii-chat-web-deploySkill
- sentry-commit-messagesSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 6 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Use the repository's abstractions and pipelines.
- Very specific: line 12
Keep reusable, platform-independent helpers in the appropriate lib/ module, especially lib/util/ with matching public declarations under …
- Distinctive: line 17
Do not log a warning and continue with invalid or partial state.
- Very specific: line 23
Use SAFE_MALLOC, SAFE_CALLOC, and the matching tracked resize/free helpers instead of raw malloc, calloc, realloc, or free.
- Distinctive: line 25
Every allocation needs one clear owner and one matching cleanup path.
- Very specific: line 26
After SAFE_FREE(ptr), set the pointer to NULL when it remains in scope.
- Distinctive: line 27
Do not replace a tracked allocation with an untracked allocation, or mix allocator families.
- Very specific: line 40
Place each defer directly in a compound block.
- Very specific: line 47
Do not use defer in .c files included by other source files, in header function bodies, or with inline assembly in a function with defer.
- Very specific: line 57
Use debug/backtrace.h APIs (backtrace_capture, backtrace_symbolize, backtrace_print, backtrace_format) rather than ad-hoc platform code.
- Distinctive: line 92
When implementation work changes a public API, option, transport, subsystem, screen, keyboard binding, platform path, test workflow, or …
- Distinctive: line 98
Keep public-header Doxygen comments and the higher-level topic page consistent.
- Distinctive: line 102
When changing a public header, option, packet, or exported WASM function, search for generated documentation, bindings, serialization, …
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
ascii-chat C development
Use the repository's abstractions and pipelines. Before changing behavior, find the existing API in include/ascii-chat/, its implementation in lib/, and the mode/pipeline caller in src/; extend one path instead of creating protocol-specific or mode-specific duplicates.
Keep reusable, platform-independent helpers in the appropriate lib/ module, especially lib/util/ with matching public declarations under include/ascii-chat/util/. Keep application, mode, orchestration, and other non-library code in src/. Do not put reusable library logic in a mode directory or duplicate a utility inside src/.
Errors and failure handling
- Functions that can fail return
asciichat_error_t, notint; invalid parameters are errors too. UseSET_ERRNO(ERROR_..., "context: %s", ...)and propagate the result. - Do not log a warning and continue with invalid or partial state. Handle the error, return nonzero, terminate the failing thread, or use the project's panic/exit path so the failure is resolved.
- The errno context is a stack and captures a backtrace. When a fallback is intentional and succeeds, clear/consume the expected error before returning success; do not leave stale errno state.
- Use the logging system, never
printf/fprintffor diagnostics. UI-facing errors go through the TUI notice/error-popup path; the popup can display the saved error and its backtrace. Live TUIs include splash, status/discovery status, help, and error/notice screens; press?for interactive keyboard help.
Tracked memory
- Use
SAFE_MALLOC,SAFE_CALLOC, and the matching tracked resize/free helpers instead of rawmalloc,calloc,realloc, orfree. These wrappers integrate allocation tracking, leak reports, and the project's failure handling. SAFE_MALLOCsizes are bytes; use checked size arithmetic before allocation and the correct typed cast required by the macro. Use aligned/SIMD allocation helpers only when the consumer requires that alignment.- Every allocation needs one clear owner and one matching cleanup path. Document ownership for buffers crossing APIs, transfer ownership explicitly, and do not free framebuffer or pool data owned by another subsystem.
- After
SAFE_FREE(ptr), set the pointer toNULLwhen it remains in scope; make cleanup paths safe for partially initialized objects and repeated teardown. - Do not replace a tracked allocation with an untracked allocation, or mix allocator families. If an external library requires its own allocator, use that library's matching release function and document the boundary.
- Allocation failure is not a warning to ignore: propagate the
asciichat_error_t, unwind the object, or use the project's fatal path as appropriate. Keep allocation and leak-report work out of realtime audio/video loops.
Block-scoped cleanup with defer
- Include
<ascii-chat/tooling/defer/defer.h>in a project.cfile. CMake transforms the source before compiling it; generated files underbuild/defer_transformed/are build artifacts and must not be edited. defer(action);registers cleanup when execution reaches it. Actions run in reverse registration order at block exit, including return, break, continue, and supported goto exits; their expressions use values at cleanup time. Return expressions are evaluated before cleanup.longjmp, process termination, and panic do not run the actions.- Place each defer directly in a compound block; brace conditional and loop
bodies. Use
defer_named(handle, action)anddefer_cancel(handle)for explicit ownership transfer. For tracked allocations, includecommon.hand useSAFE_MALLOC_DEFER_FREE(name, size, pointer_type)orSAFE_CALLOC_DEFER_FREE(name, count, size, pointer_type); set the local pointer toNULLafter transferring ownership. Preserve resource release ordering, synchronization lifetimes, and allocator families. - Do not use defer in
.cfiles included by other source files, in header function bodies, or with inline assembly in a function with defer. Unsupported control flow and macro forms must fail the build; do not work around a diagnostic by silently skipping cleanup. Seedocs/topics/defer.doxfor restrictions, macro wrappers,--explain,--show-transformed, and LLVM development dependencies. Test success and error/transfer paths for the affected subsystem.
Backtraces and synchronization debugging
Use debug/backtrace.h APIs (backtrace_capture, backtrace_symbolize, backtrace_print, backtrace_format) rather than ad-hoc platform code. Debugging support is build-dependent; line/function quality depends on symbols, frame pointers, dSYM/PDB/debug info, and the platform symbolizer. WASM uses stubs and does not provide native traces.
Errors, crash handlers, explicit --backtrace, and selected debug paths capture traces automatically. Symbolization is comparatively expensive and may batch/launch llvm-symbolizer or equivalent, so never capture or symbolize once per audio/video frame or inside a realtime render loop. Capture at lifecycle boundaries, failures, or a sampled/debug-only path; symbolize when presenting the diagnostic.
For hangs, use --sync-state and the sync-debug APIs, especially delayed collection such as debug_sync_print_backtrace_delayed(...), to inspect mutexes, conditions, threads, and lock owners without immediately perturbing the deadlock. On supported non-Windows debug builds, SIGUSR1 triggers synchronization state, errno-stack, and diagnostic-stat reports; SIGUSR2 requests a deferred memory report handled by the diagnostics worker. Then inspect the emitted logs/TUI. Reproduce with --log-file, --grep, and an appropriate non-release debug build.
Thread lifecycle and shutdown
For every worker, mutex, condition, callback, and queue, identify its owner and lifecycle. Startup failures must unwind resources already created; cleanup must be safe to call once and must not join a worker while holding a lock that worker needs. Preserve the project's shutdown ordering and bounded-join conventions when handling degraded cleanup.
Transports, crypto, and media
- Network C code uses abstract transport APIs and the shared packet/session pipelines. Think in transports (TCP, WebSocket, WebRTC/DTLS, etc.), not duplicated implementations per protocol.
- The custom encrypted session uses ephemeral X25519-style key exchange and authenticated encryption; password and SSH/Ed25519 identity modes add authentication/TOFU. HTTPS/TLS belongs to the platform/network transport and key-fetch paths; DTLS is provided by the WebRTC transport. Reuse the existing handshake and transport layers.
- Media flows through FFmpeg and shared decoder/encoder pipelines. Raw pixel frames are internal buffers; H.264/H.265 use FFmpeg codec contexts (including
libx264where available), and rendering consumes decoded frames rather than inventing a second conversion path. Check the active build's FFmpeg codecs and OS support before promising a format. - Sources include webcams, microphones, speakers, local files, HTTP/HTTPS/RTSP/HLS and other FFmpeg inputs; yt-dlp resolves supported complex sites before FFmpeg. Preserve capability probing, defaults, resolution/FPS/sample-rate negotiation, and error propagation.
ASCII rendering
The renderer converts owned pixel/image buffers into terminal cells at high FPS using scalar or SIMD implementations. Preserve buffer ownership, dimensions/stride, palette and capability negotiation, and row-run/RLE output optimizations. The two text renderer choices are the luminance and glyph renderers; inspect options.h and renderer code for current defaults/palettes rather than hard-coding them. Keep hot loops allocation-free and free of logging, symbolization, or blocking I/O.
WASM
src/web and lib/platform/wasm provide browser bindings and stubs. Do not add native/OS dependencies to WASM unless explicitly requested. Guard non-WASM includes and code with the existing build conditionals and add/update a stub when the API must exist in the browser build.
Build and review habits
On Windows, use the native PowerShell environment, Scoop/LLVM Clang, Ninja, and the default preset. Reconfigure with cmake --preset default -B build and build with cmake --build build; plain Ninja builds use all available cores by default, so do not add -j or --parallel build flags. Do not substitute MSVC or GCC. On Linux/macOS, use the cross-platform skill for the prescribed Docker or SSH environment. Always use the main worktree's .deps-cache/ for shared source-built dependency caches; do not create a separate dependency cache inside a temporary worktree. The CMake layout is organized under cmake/ by dependencies, compiler/toolchain/platform setup, targets, install, tests, utilities, and scripts—extend the appropriate module instead of placing platform or dependency logic in arbitrary top-level files. Required dependencies must be required and linked where symbols are used; conditionals must represent real platform/feature variants. Use SAFE_MALLOC/CALLOC/FREE, platform abstractions, and documented ownership. Check Doxygen comments and generated interfaces when changing public headers. Run the narrowest relevant build/tests, then broader tests when the change crosses pipelines or platforms. Use recent git history as context for recurring failure areas: CMake/dependency selection, webcam/media capability probing, synchronization, renderer performance, and cross-platform/WASM boundaries.
For test selection, Criterion/JUnit/coverage, or test diagnosis, also load ascii-chat-testing. For Linux Docker or macOS SSH builds, compiler selection, cache preservation, or cross-platform artifact inspection, also load ascii-chat-cross-platform-development-and-or-testing.
When the task is complete, the code is merged into the main worktree, and the changes are pushed, remove obsolete build directories and temporary git worktrees created during the task. Verify the target paths first; preserve the main worktree, its active build/, uncommitted user work, and any worktree still needed by another task.
Documentation synchronization
When implementation work changes a public API, option, transport, subsystem,
screen, keyboard binding, platform path, test workflow, or user-visible
behavior, update or create the relevant Doxygen topic or authored guide in the
same change. Do not leave documentation as follow-up work. Load and follow
ascii-chat-documentation for topic
placement, navigation, stale-content review, and docs-only verification.
Keep public-header Doxygen comments and the higher-level topic page consistent;
document the current abstraction and ownership model rather than copying an
old implementation detail.
When changing a public header, option, packet, or exported WASM function, search for generated documentation, bindings, serialization, tests, and platform stubs before finishing. Keep Doxygen comments and generated interfaces synchronized.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

