Codebuff LogoCodebuff

Codebuff Best Practices

Learn how to use Codebuff to streamline your code review process.

Start in a Git Repo

Ensure you're in a Git repository before starting Codebuff. This will allow you to track changes that Codebuff makes to your code.

If Codebuff introduces an issue you don't like, you can easily revert to the previous version.

Leverage .gitignore in your repo

Codebuff will ignore files specified in your .gitignore file. This allows you to specify files that you don't want Codebuff to read, like configuration files or build artifacts.

If there are files you want to keep tracked in Git, but you don't want Codebuff to read, you can create a .codebuffignore file in your repo.

Planning

Codebuff is really good at ad-hoc changes, but sometimes you have bigger features to build. You can ask Codebuff to help plan out all the details of your feature before you start coding!

Do a long brain dump of your feature, with as much technical detail as you want to consider. Don't worry about formatting it nicely.

Then, ask Codebuff to re-word what I said in a goal-oriented plan, and output that to a plan.md` file in markdown format.

Codebuff will write out what it thinks is the best way to implement your feature, and you can use that as a starting point! Make sure to read through it carefully and adjust anything needed.

Then, you can simply ask Codebuff to build the feature, using the plan.md file you both collaborated on as a guide.

Where Codebuff Shines

Refactor Files

Codebuff excels at rewriting and reorganizing code. Here are some examples of what it can do:

  • Convert files between languages while preserving functionality
  • Update code to use new APIs or libraries
  • Implement consistent patterns across your codebase
  • Reorganize file structure for better maintainability

If you have projects with particular patterns and styles, Codebuff can help you keep them consistent as you develop.

Multi-file Edits

No more copy/paste! Codebuff is particularly good at making changes that involve multiple files:

  • Rename functions, classes, or variables across the entire codebase
  • Update API endpoints and their corresponding client code
  • Modify shared types and update all their usages
  • Add new features that require changes in multiple parts of the application

Code Generation

Codebuff can help generate boilerplate code and common patterns:

  • Create new API endpoints with proper logging and error handling
  • Generate TypeScript types from existing code
  • Add test cases for new functionality
  • Create documentation files in markdown format

Terminal Integration

Codebuff can run terminal commands to help with development tasks:

  • Install new dependencies with the correct package manager
  • Run type checks and tests after making changes
  • Search through code using grep or other tools
  • Move, rename, or delete files as part of refactoring

Knowledge Management

Codebuff maintains knowledge files (files ending in knowledge.md) that capture important context about your codebase:

  • Project-specific patterns and conventions
  • Architecture decisions and their rationale
  • Best practices for different parts of the codebase

Feel free to update them as you see fit! Codebuff will load your codebase's knowledge files every time it starts up, so it has full context into your project's unique needs and quirks.

Knowledge Files

Codebuff uses knowledge files to store project-specific information and best practices. These files help Codebuff understand your project's context and requirements.

Getting Started

You can ask Codebuff to create an initial knowledge file for your project:

Or create one manually:

  1. Create a knowledge.md file at the root of your project:
  1. For larger projects, you can optionally create additional knowledge files in subdirectories:

This organization helps keep knowledge specific to different parts of your codebase close to the relevant code.

What to Include

Knowledge files should contain information that isn't obvious from the code itself:

  • Project goals and mission
  • Technical decisions and their rationale
  • Coding standards and best practices
  • Common pitfalls to avoid
  • Tips for working with project-specific tools
  • Links to important documentation
  • Build and deployment requirements
  • Testing guidelines
  • Verification commands to run after changes (e.g., npm run build, npm run lint, or npm test)

Don't worry about keeping knowledge files too short - they can grow to a couple hundred lines without impacting performance or cost. Focus on capturing useful information rather than minimizing file size.

Post-Change Verification

You can specify commands that Codebuff should run after making changes to verify everything still works. For example:

## Verifying Changes

After any code changes, run these commands to verify correctness:
- Run `npm run typecheck` to check for type errors
- Run `npm test` to ensure tests pass

When these commands are specified in a knowledge file, Codebuff will automatically run them after making changes to confirm the edits are valid.

Remember: Knowledge files should capture information that would be valuable for new team members or for refreshing your own memory after time away from the project.

Version Control Features

Undo and Redo Changes

If Codebuff makes a change you don't like, you can easily undo it:

  • Type undo or u to remove the last change
  • Type redo or r to reapply a change you undid
  • Type diff or d to see what changes were made in the last response

These commands work like your editor's undo/redo, making it easy to experiment with changes while keeping your code safe.

Of course, if you use Git, you can always restore files to previous versions.

Git Integration

Codebuff works alongside your existing git workflow:

  • Changes are made to your working directory
  • You maintain control over what gets committed
  • Review changes with git diff before committing
  • Use normal git commands to manage your repository

You can also use Codebuff to create commit messages, just ask it to do so:

Tips & Tricks