Full Code of KrauseFx/twitter-unfollow for AI

master 7471dc6a8154 cached
5 files
4.2 KB
1.1k tokens
4 symbols
1 requests
Download .txt
Repository: KrauseFx/twitter-unfollow
Branch: master
Commit: 7471dc6a8154
Files: 5
Total size: 4.2 KB

Directory structure:
gitextract_ndc21pl8/

├── .gitignore
├── Gemfile
├── LICENSE
├── README.md
└── unfollow.rb

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
.keys
unfollowed_full_names.txt
unfollowed_usernames.txt


================================================
FILE: Gemfile
================================================
source "https://rubygems.org"

gem "twitter"
gem "pry"


================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2017 Felix Krause

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
# twitter-unfollow

> My goal for the next months is to spend less time on social media and more time creating. Instead of reacting to things, I want to focus on having a bigger vision, planning things ahead and doing what has the highest impact.
> 
> I've been reading every single tweet in my timeline for the last 4 years with no interruption.
> 
> In total I have over 100 custom mute filters, including custom regexes like `(@United|delta|Delta|JetBlue|jetblue)`), and muted clients like Buffer
>
> It's time for me to stop reading so much on social media portals, and focus on reading books instead.
> 
> I'll still follow a small amount of people via Twitter lists, since there are certain things I really don't want to miss

![unfollow.gif](unfollow.gif)

[View full blog post on my Twitter setup](https://krausefx.com/blog/how-i-use-twitter)

This script does the following:

- Unfollow everybody
- Puts them into a list called "Old Follows"
- Store the usernames of everyone in `unfollowed_usernames.txt` (this allows you to pretty easily follow everyone again when you feel like it)
- Store the usernames, together with full name and bio into `unfollowed_full_names.txt` (this allows you to search for users)

```
bundle install
bundle exec ruby unfollow.rb
```

## Notes:
- Make sure to have DMs open to still be able to chat with your friends.
- Use a list to follow a small subset of people. This way you follow 0 people and nobody feels left out. The list can be private.
- Make sure to create a list called "Old Follows"

## Technical Notes
- Create your application via [Twitter Apps](https://apps.twitter.com)
- Set the following environment variables
  - `ENV["CONSUMER_KEY"]`
  - `ENV["CONSUMER_SECRET"]`
  - `ENV["ACCESS_TOKEN"]`
  - `ENV["ACCESS_TOKEN_SECRET"]`
- Due to the API limits this script can only unfollow about 420 people per run. You'll need to regenerate keys after this 🤷‍♀️

[View full blog post on my Twitter setup](https://krausefx.com/blog/how-i-use-twitter)


================================================
FILE: unfollow.rb
================================================
require 'twitter'
require 'shellwords'

class Unfollow
  def run
    raise "Please create a list called 'Old Follows'" if old_follows_list.nil?
    followings = client.following

    followings.each do |user|
      next if user.screen_name == "KrauseFx" # trolololol

      puts "Unfollowing user #{user.screen_name} (#{user.name})"
      client.add_list_member(old_follows_list, user.id)
      client.unfollow(user.id)
      `echo "#{user.screen_name.shellescape}" >> unfollowed_usernames.txt`
      `echo "#{user.screen_name.shellescape} (#{user.name.shellescape}): #{user.description.shellescape}" >> unfollowed_full_names.txt`
      sleep 1
    end
  end

  def old_follows_list
    @_old_follows_list ||= client.lists.find { |a| a.name == "Old Follows" }
  end

  def client
    client = Twitter::REST::Client.new do |config|
      config.consumer_key        = ENV["CONSUMER_KEY"]
      config.consumer_secret     = ENV["CONSUMER_SECRET"]
      config.access_token        = ENV["ACCESS_TOKEN"]
      config.access_token_secret = ENV["ACCESS_TOKEN_SECRET"]
    end
  end
end

Unfollow.new.run
Download .txt
gitextract_ndc21pl8/

├── .gitignore
├── Gemfile
├── LICENSE
├── README.md
└── unfollow.rb
Download .txt
SYMBOL INDEX (4 symbols across 1 files)

FILE: unfollow.rb
  class Unfollow (line 4) | class Unfollow
    method run (line 5) | def run
    method old_follows_list (line 21) | def old_follows_list
    method client (line 25) | def client
Condensed preview — 5 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (5K chars).
[
  {
    "path": ".gitignore",
    "chars": 57,
    "preview": ".keys\nunfollowed_full_names.txt\nunfollowed_usernames.txt\n"
  },
  {
    "path": "Gemfile",
    "chars": 55,
    "preview": "source \"https://rubygems.org\"\n\ngem \"twitter\"\ngem \"pry\"\n"
  },
  {
    "path": "LICENSE",
    "chars": 1069,
    "preview": "MIT License\n\nCopyright (c) 2017 Felix Krause\n\nPermission is hereby granted, free of charge, to any person obtaining a co"
  },
  {
    "path": "README.md",
    "chars": 1999,
    "preview": "# twitter-unfollow\n\n> My goal for the next months is to spend less time on social media and more time creating. Instead "
  },
  {
    "path": "unfollow.rb",
    "chars": 1097,
    "preview": "require 'twitter'\nrequire 'shellwords'\n\nclass Unfollow\n  def run\n    raise \"Please create a list called 'Old Follows'\" i"
  }
]

About this extraction

This page contains the full source code of the KrauseFx/twitter-unfollow GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 5 files (4.2 KB), approximately 1.1k tokens, and a symbol index with 4 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!