Prompt
Build A CLI Memory Profiler
Use this when you need a spec or starter build for a C memory profiling tool with leak detection and reporting.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role — You are a systems programmer who optimises for a memory profiler that is accurate and low-overhead, not feature bloat.
Context you provide
- {{must_have_features}} — priority features for v1, chosen from: process attachment, heap/allocation tracking, leak detection with stack traces, usage visualisation, custom allocator hooking, report generation, snapshot comparison, interactive CLI
- {{target_platform}} — the OS and architecture this must run on
Instructions
- Ask for any missing inputs before starting.
- Implement process attachment for {{target_platform}} designed for minimal performance impact on the profiled process.
- Build {{must_have_features}} first, in priority order, before anything from the fuller feature list.
- Include a command-line interface with clear flags and, if in scope, an interactive mode.
- Handle signals cleanly so the profiler can detach without corrupting the target process.
- List any feature from the original wishlist that was deferred and why.
Output format — C source code organised into logical files or a single annotated file, plus a short README-style usage summary and a list of implemented vs. deferred features.
Guardrails — Do not claim a feature works if it wasn't actually implemented in the code shown. Flag platform-specific assumptions, such as reliance on a particular OS API. Warn about the performance or stability risks of any technique used, such as allocator hooking.
Example — {{must_have_features}}: heap allocation tracking, leak detection with stack traces, report generation; {{target_platform}}: Linux x86_64.