0%
Reading Settings
Font Size
18px
Line Height
1.5
Letter Spacing
0.01em
Font Family
Table of contents
    blog cover

    Maybe You Don't Need Another Dependency In The AI Era

    Software Engineer
    Software Engineer
    published 2026-11-28 15:28:32 +0700 ·
    4 mins read
    For years, software developers have been encouraged not to reinvent the wheel.
    Need to process CSV files? Find a library.
    Need to handle dates? There is probably a library for that.
    Need soft deletion in Rails? Install paranoia
    ...

    This approach makes sense. Libraries save development time, provide reusable functionality, and allow us to focus on building our applications instead of implementing everything from scratch. But AI is changing this equation. Today, we can describe a requirement to an AI coding assistant and get a working implementation in seconds. So I've started asking myself a different question:
    Do I really need another dependency, or can I just write the small piece of code I actually need?

    1. The hidden cost of dependencies

    Installing a package is easy. Maintaining it is another story. Every dependency introduces additional considerations:
    • Security vulnerabilities and potential attack surface.
    • Compatibility with future versions of our language and framework.
    • Maintenance and update requirements.
    • Breaking changes and deprecated APIs.
    • Additional complexity when debugging production issues.
    • The possibility that the project becomes abandoned.
    None of this means dependencies are bad. In fact, mature libraries often save us from serious bugs and months of implementation work. But sometimes we install an entire library just to use one small feature. That's where I think we should reconsider our approach.

    2. You might only need 5% of the package

    Let's take soft deletion as an example.
    In a Rails application, we might install paranoia:
    // language: ruby
    class Post < ApplicationRecord
      acts_as_paranoid
    end
    This provides a convenient interface for soft deletion. But what if our actual requirements are only:
    • Add a deleted_at column.
    • Hide deleted records by default.
    • Override destroy to mark records as deleted.
    • Restore deleted records.
    • Query deleted records.
    We might be using only a small subset of what the library provides. With AI, we can ask it to implement precisely those requirements using existing Rails functionality. 
    A small reusable concern could provide a simplified Paranoia-style API without introducing another gem. We aren't trying to recreate Paranoia. We're implementing only the functionality our application actually needs.

    A simplified Paranoia-style implementation

    First, add a migration:
    // language: ruby
    class AddDeletedAtToPosts < ActiveRecord::Migration[8.0]
      def change
        add_column :posts, :deleted_at, :datetime
        add_index :posts, :deleted_at
      end
    end

    Then create a reusable concern:
    // language: ruby
    # app/models/concerns/soft_deletable.rb
    
    module SoftDeletable
      extend ActiveSupport::Concern
    
      included do
        default_scope { where(deleted_at: nil) }
      end
    
      class_methods do
        def with_deleted
          unscope(where: :deleted_at)
        end
    
        def only_deleted
          with_deleted.where.not(deleted_at: nil)
        end
      end
    
      def destroy
        update_column(:deleted_at, Time.current)
        self
      end
    
      def delete
        destroy
      end
    
      def restore
        update_column(:deleted_at, nil)
        self
      end
    
      def deleted?
        deleted_at.present?
      end
    
      def really_destroy!
        self.class.unscoped.where(id: id).delete_all
      end
    end

    Include it in the model:
    // language: ruby
    class Post < ApplicationRecord
      include SoftDeletable
    end

    Now we have a familiar interface:
    // language: ruby
    post = Post.find(1)
    
    # Soft delete
    post.destroy
    
    # Deleted records are hidden by default
    Post.all
    
    # Find all records, including deleted ones
    Post.with_deleted
    
    # Find only deleted records
    Post.only_deleted
    
    # Restore
    post.restore
    
    # Permanently delete
    post.really_destroy!

    No additional gem required.

    Of course, this is a deliberately minimal implementation, not a drop-in replacement for Paranoia. Overriding Active Record's destroy and delete bypasses normal destruction behavior, including callbacks and dependent association handling. It also doesn't reproduce Rails' destroyed-record state. A production implementation needs to decide how to handle these semantics, transactions, associations, uniqueness constraints, and concurrent updates.

    The point isn't to recreate every feature of Paranoia. It's to recognize when we only need a small subset of its functionality.

    3. AI makes small custom implementations much cheaper

    This is the biggest change for me. Previously, writing a custom implementation meant spending time researching APIs, reading documentation, considering edge cases, and testing everything. Sometimes installing a package was simply faster.
    Now I can describe what I need to an AI coding assistant:
    I need a small utility that retries an asynchronous operation up to three times.Use only built-in language features. Don't install any dependencies.Keep the implementation simple, handle errors correctly, and explain potential edge cases.
    AI can generate the implementation, explain its behavior, and suggest improvements. I can also ask it to:
    • Compare a custom implementation with an existing package.
    • Identify unnecessary features.
    • Review security implications.
    • Generate unit tests.
    • Find edge cases.
    • Simplify the implementation.
    This changes the economics of building small utilities. Instead of spending time searching for the perfect package, I can often build exactly what I need. Of course, AI-generated code still needs review and testing. Faster implementation doesn't automatically mean safer implementation.

    4. But don't reinvent everything

    I don't think we should replace every dependency with custom code. Some things are difficult for good reasons.
    For example:
    • Cryptography and encryption.
    • Authentication and authorization.
    • Payment processing.
    • Complex date and timezone handling.
    • Database engines and query builders.
    • Image and video processing.
    • Distributed systems and message queues.
    These areas have complicated edge cases, security implications, and years of engineering behind established libraries.  Reimplementing them just to save a dependency can be a terrible trade-off.

    I don't think we should replace every dependency with custom code. Some things are difficult for good reasons. For example:
    • Simple utilities: Write a small implementation when the requirement is straightforward.
    • Built-in functionality: Use what your programming language or framework already provides.
    • Small subset of a package: Consider implementing only the features you actually need.
    • Complex functionality: Prefer established libraries that have already solved difficult edge cases.
    • Security-critical functionality: Prefer well-reviewed, maintained solutions rather than experimenting with custom implementations.
    The goal isn't to minimize the number of dependencies at all costs. It's to avoid unnecessary complexity.

    Conclusion

    I still believe in reusing code. Libraries are one of the best things about modern software development. But AI gives us another option that wasn't nearly as accessible before. We can now describe a small requirement, generate an implementation, review it, write tests, and maintain it ourselves without spending hours building everything from scratch. Sometimes installing a package is still the best decision. But sometimes, installing an entire library for a few lines of functionality is unnecessary.

    In the AI era, perhaps we should stop asking which package solves our problem and start asking how much of that package we actually need.

    Maybe the best dependency is the one we never needed to install.