Notes
AI coding agent bootstrapping
Planning and implementing
Before implementing any new solution, feature, or functionality, always research and consult authoritative documentation sources to ensure correct implementation. This includes:
Required Research Steps:
- Official Documentation: Check the official documentation for libraries, frameworks, APIs, or technologies being used
- Language References: Consult official language specifications, style guides, and best practices for the programming language
- Standards and Specifications: Review relevant industry standards (ISO, IEEE), RFCs for protocols, or specification documents for the technology domain
- API Documentation: Study complete API references, including parameters, return values, error handling, and usage examples
Implementation Guidelines:
- Use the
resolve-library-id
andget-library-docs
tools to fetch current documentation for specific libraries - Use
web-search
to find official documentation, RFCs, or standards when not available through other tools - Verify implementation patterns against official examples and recommended practices
- Check for version-specific requirements, deprecations, or breaking changes
- Understand error handling, edge cases, and limitations before coding
Documentation Priority Order:
- Official project/library documentation
- Language-specific official references (e.g., Python PEPs, JavaScript MDN, Rust Book)
- Relevant RFCs for protocols (HTTP, WebSocket, etc.)
- Industry standards and specifications
- Authoritative third-party resources (when official docs are insufficient)
This research phase should be completed before writing any implementation code to ensure correctness, security, and adherence to established patterns.
Create a comprehensive task list to track and manage the work for this project. The task list should:
- Break down the overall objective into specific, actionable tasks that each represent meaningful units of work (approximately 20 minutes each for a professional developer)
- Organize tasks hierarchically with subtasks where appropriate
- Keep the task list current and up-to-date throughout the work process
- Update task states as work progresses:
- Mark tasks as “In Progress” when actively working on them
- Mark tasks as “Complete” when finished
- Add new tasks as requirements become clearer
- Modify task descriptions if scope changes
Use the task management tools (add_tasks, update_tasks, view_tasklist) to maintain this list throughout our work session. Update the task states efficiently using batch operations when transitioning between tasks. The task list should serve as both a planning tool and a progress tracker for the entire project.
Coding
When writing code, follow these software engineering best practices:
Module Structure:
- Organize code into well-defined modules with clear responsibilities and single purposes
- Use descriptive module names that reflect their functionality
- Implement proper separation of concerns between modules
- Create logical module hierarchies and avoid circular dependencies
Function Design:
- Keep functions focused on a single responsibility (Single Responsibility Principle)
- Limit function length to 20-30 lines when possible for better readability and maintainability
- Use descriptive function names that clearly indicate their purpose
- Minimize function parameters (ideally 3 or fewer)
Code Reusability (DRY Principle):
- Identify and extract common code patterns into reusable functions or classes
- Create utility modules for shared functionality across the codebase
- Use configuration files or constants for repeated values
- Implement inheritance or composition patterns where appropriate to avoid code duplication
File Organization:
- Keep source files under 300-500 lines when possible
- Split large files into multiple focused modules based on functionality
- Group related functions and classes into the same module
- Use clear file naming conventions that reflect the module’s purpose
- Consider creating separate files for interfaces, implementations, utilities, and tests
Additional Guidelines:
- Maintain consistent coding style and naming conventions throughout the project
- Add clear documentation and comments for complex logic
- Ensure proper error handling and input validation
- Write unit tests for new functions and modules
Mocking and Placeholders
Do not implement mock or placeholder implementations. Always provide fully functional, production-ready code that integrates with real systems and APIs. When working with external services, libraries, or protocols, use the actual implementation rather than creating simulated or dummy versions. If there are platform limitations (such as web vs native), implement proper conditional logic or platform-specific solutions rather than mocking the functionality. The goal is to create working software that can be deployed and used with real hardware/services, not demonstrations or prototypes.
Testing
Create comprehensive unit tests for the code that has been implemented. Run the tests to verify they pass. If any tests fail:
- Do NOT modify the test code to make it pass - the tests define the expected behavior
- Instead, fix the implementation code to meet the requirements defined by the tests
- Iterate on the implementation until all tests pass successfully
- Ensure tests cover:
- Normal/happy path scenarios
- Edge cases and boundary conditions
- Error handling and invalid inputs
- Integration points between modules
The tests serve as the specification for correct behavior. When there’s a discrepancy between the implementation and tests, always assume the tests are correct and modify the implementation accordingly. Only modify tests if there’s a genuine error in the test logic itself (not because the implementation doesn’t match the expected behavior).
After making implementation changes, re-run the tests to confirm they pass before considering the work complete.
Tools
When working on development tasks, leverage existing command-line development tools available on the system rather than reinventing functionality. Before using any tools, check if they are installed and ask the user to install missing dependencies if needed for successful development.
Examples of preferred tools to use:
- Search and code analysis: grep, ack, ripgrep (rg), ag (the_silver_searcher), locate, find
- Debugging: gdb (GNU Debugger), lldb, strace (system call tracing), ltrace (library call tracing)
- Memory analysis: valgrind (memory leak detection, profiling), AddressSanitizer, MemorySanitizer
- Performance profiling: perf, gprof, callgrind
- Build tools: make, cmake, ninja, autotools
- Version control: git commands for advanced operations
- Static analysis: cppcheck, clang-static-analyzer, pylint, eslint
When a development task could benefit from these tools:
- First check if the required tool is available using
which <tool>
or similar - If not available, inform the user about the missing tool and provide installation instructions for their platform
- Use the appropriate tool with proper command-line arguments for the specific task
- Explain the output and results to help the user understand what was discovered
This approach ensures we use battle-tested, efficient tools that developers rely on rather than implementing custom solutions for common development tasks.
Clean Build
After completing each development cycle or major set of changes, perform a clean build and test run to verify there are no issues with stale dependencies, cached artifacts, or outdated libraries. This should include:
- Clear any build caches, temporary files, or compiled artifacts
- Reinstall dependencies from scratch (e.g., delete node_modules and run npm install, clear pip cache, etc.)
- Perform a fresh build of the entire project
- Run the full test suite to ensure all functionality works correctly
- Verify the application starts and core features function as expected
This clean verification step helps catch dependency conflicts, version mismatches, or caching issues that might not be apparent during incremental development but could cause problems in production or for other developers.
Source Version Control
Initialize a Git repository for the application project if one does not already exist. After each successful test run that validates functionality (such as successful app compilation, UI functionality verification, or feature testing), create a Git commit with the following requirements:
- Stage all relevant changed files using
git add
- Write comprehensive commit messages that include:
- A clear, concise summary line (50 characters or less)
- A detailed description explaining what was changed and why
- Reference any specific issues or features addressed
- Note any breaking changes or important considerations
- Use conventional commit format when applicable (feat:, fix:, docs:, etc.)
- Ensure commits are made only after verifying that:
- The application compiles without errors
- Core functionality works as expected
- No critical bugs are introduced
- Create logical, atomic commits that represent complete, working changes rather than partial or broken states,
Example commit message format:
```
feat: implement ONVIF camera discovery for web platform
- Replace NetworkInterface.list() with web-compatible discovery
- Add platform-specific conditional logic for web vs native
- Implement proper error handling for network operations
- Tested successfully in Chrome browser environment
Fixes discovery button functionality in web deployment
```
CRITICAL: Never automatically restore, revert, or checkout code from the git repository without first:
- Explicitly asking the user for permission
- Clearly explaining what changes will be lost or overwritten
- Receiving explicit user approval before proceeding
This applies to all git operations that would modify the working directory, including but not limited to:
git checkout
(files or branches)git reset --hard
git restore
git revert
git stash pop/apply
- Any other commands that would overwrite current file contents
Always preserve user work and modifications unless explicitly instructed otherwise. When suggesting git operations that could affect current changes, first recommend checking git status
and git diff
to show what would be affected, then wait for user confirmation.