Ai Coding Tools

How to Write Cleaner Code with AI Tools in Just 2 Hours

By BTW Team4 min read

How to Write Cleaner Code with AI Tools in Just 2 Hours

In the fast-paced world of coding, writing clean code is not just a best practice; it's essential for maintaining and scaling projects effectively. But let’s face it—between deadlines and feature requests, it can be tough to prioritize clean coding practices. That’s where AI tools can come in handy. In this article, I’ll walk you through how to leverage these tools to improve your code quality in just 2 hours.

Prerequisites: What You’ll Need

Before diving in, here’s what you’ll want to have ready:

  • A code editor (VS Code, JetBrains, etc.)
  • Basic coding knowledge (Python, JavaScript, etc.)
  • An account with a couple of AI tools (see our tool list below)

Step 1: Choose Your AI Tools (30 minutes)

Here’s a list of AI tools that can help you write cleaner code. Each tool has its strengths, limitations, and pricing models.

| Tool Name | What It Does | Pricing | Best For | Limitations | Our Take | |------------------|------------------------------------|-----------------------------|---------------------------------|----------------------------------|-------------------------------| | GitHub Copilot | AI-powered code suggestions | $10/mo, free trial available| Quick code snippets | Limited to popular languages | We use this for rapid prototyping. | | CodeGuru | Code reviews and performance insights| $19/user/month | Java and Python projects | Limited to AWS ecosystem | We don’t use this due to AWS lock-in. | | Tabnine | Code completion suggestions | Free tier + $12/mo pro | Multiple languages | Some suggestions can be off-base | We find it helpful for JavaScript. | | SonarLint | Real-time code quality feedback | Free | Static code analysis | Limited to IDE integrations | We use this for ongoing projects. | | DeepCode | AI-driven code review | Free tier + $12/mo pro | Security vulnerabilities | Sometimes misses edge cases | We don’t use it as much anymore. | | ReSharper | Code analysis and refactoring tools| $149/year | .NET languages | Pricey for solo devs | We stopped using it due to cost. | | Codacy | Automated code reviews | Free tier + $15/user/month | Continuous integration | Can be complex to set up | We use this for CI/CD pipelines. | | Kite | AI-powered coding assistant | Free | Python and JavaScript | Limited language support | We love it for Python projects. | | JSHint | JavaScript code quality tool | Free | JavaScript only | Doesn’t catch all errors | We don’t use it anymore. | | ESLint | Linting tool for JavaScript | Free | JavaScript and TypeScript | Requires configuration | We use this religiously. |

What We Actually Use

In our stack, we primarily rely on GitHub Copilot for initial coding, SonarLint for ongoing quality checks, and ESLint for JavaScript projects. This combination has worked wonders for us, especially when shipping products quickly while keeping the code clean.

Step 2: Set Up Your Environment (15 minutes)

  1. Install your chosen tools: Most of these tools have straightforward installation processes. Follow the documentation for each tool to integrate them into your code editor.

  2. Configure the settings: Spend a few minutes adjusting settings based on your coding style and preferences. For instance, in ESLint, you can set rules that enforce your code style.

Step 3: Write Clean Code with AI Assistance (45 minutes)

Now that you have your tools set up, it’s time to write some code. Here’s a simple workflow:

  1. Start with a clean slate: Create a new project or file.

  2. Code with AI suggestions: As you write, pay attention to the suggestions provided by GitHub Copilot or Tabnine. They can often help you with best practices you might overlook.

  3. Run real-time checks: Use SonarLint to check for code quality issues as you code. It will flag potential problems immediately, allowing you to fix them on the spot.

  4. Refactor with AI tools: Once you have your initial code, use tools like DeepCode or Codacy for a deeper analysis. They can help you identify areas for optimization you might not catch on your own.

Step 4: Troubleshooting Common Issues (15 minutes)

Even with AI, you may run into issues. Here are some common problems and solutions:

  • AI suggestions are irrelevant: If you find the suggestions from GitHub Copilot are off, try retraining it with more context about what you’re trying to achieve.
  • Static analysis tools flag too many issues: Adjust the configuration settings to be less strict if you feel overwhelmed by warnings.
  • Integration issues: If tools like Codacy aren’t integrating well with your CI/CD pipeline, check the documentation or community forums for troubleshooting advice.

What’s Next?

Now that you’ve cleaned up your code, consider implementing a continuous integration system to maintain code quality over time. Tools like CircleCI or GitHub Actions can help automate this process.

Conclusion: Start Here

If you’re looking to write cleaner code quickly, start by integrating GitHub Copilot and SonarLint into your workflow. Spend just a couple of hours getting familiar with these tools, and you’ll find that writing clean code becomes a lot easier.

Follow Our Building Journey

Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.

Subscribe

Never miss an episode

Subscribe to Built This Week for weekly insights on AI tools, product building, and startup lessons from Ryz Labs.

Subscribe
Ai Coding Tools

How to Use GitHub Copilot to Generate Code in 30 Minutes

How to Use GitHub Copilot to Generate Code in 30 Minutes If you're a solo founder or indie hacker, you know that time is often your most valuable resource. Enter GitHub Copilot, an

Jun 1, 20264 min read
Ai Coding Tools

How to Boost Your Coding Speed with AI Tools in Just 1 Week

How to Boost Your Coding Speed with AI Tools in Just 1 Week As a solo founder or indie hacker, coding efficiency is crucial. You might find yourself wishing for more hours in the d

Jun 1, 20264 min read
Ai Coding Tools

AI Coding Tools: Cursor vs GitHub Copilot - Which Is Superior for Teams?

AI Coding Tools: Cursor vs GitHub Copilot Which Is Superior for Teams? As a founder or indie hacker, you're likely familiar with the everevolving landscape of AI coding tools. In

Jun 1, 20264 min read
Ai Coding Tools

How to Use GitHub Copilot for Creating 10 Projects in 2 Weeks

How to Use GitHub Copilot for Creating 10 Projects in 2 Weeks Creating projects quickly is a common challenge for indie hackers and side project builders. With the pressure to ship

Jun 1, 20263 min read
Ai Coding Tools

How to Speed Up Coding with AI: A 30-Minute Setup Guide

How to Speed Up Coding with AI: A 30Minute Setup Guide If you’re like me, you often find yourself buried in code, wishing you could speed up the tedious parts and focus on the crea

Jun 1, 20264 min read
Ai Coding Tools

Why Many Developers Overrate AI Coding Tools: The Hidden Pitfalls

Why Many Developers Overrate AI Coding Tools: The Hidden Pitfalls As a developer or a founder, you’ve probably heard the buzz around AI coding tools—promises of faster coding, fewe

Jun 1, 20265 min read