Cette page est affichée en anglais. Une traduction française est en cours.
SkillsMay 12, 2026·3 min de lecture

thefuck — Magnificent Command Corrector for Your Terminal

A CLI tool that corrects your previous console command by suggesting and running the right fix automatically.

Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
thefuck
Commande CLI universelle
npx tokrepo install b470ab44-4dfc-11f1-9bc6-00163e2b0d79

Introduction

thefuck is a Python CLI app that listens for failed commands in your shell and proposes corrected alternatives. When you mistype a command, forget sudo, or use wrong flags, just type fuck and it will fix and re-run the command for you.

What thefuck Does

  • Detects failed shell commands based on exit codes and stderr output
  • Matches failures against a library of built-in correction rules
  • Suggests the most likely corrected command automatically
  • Supports custom user-defined rules for project-specific workflows
  • Works across Bash, Zsh, Fish, PowerShell, and tcsh

Architecture Overview

thefuck intercepts the previous command's exit code and output via a shell alias. It then passes that context through a pipeline of rule matchers, each of which checks whether it can fix the error. Rules are plain Python modules with match() and get_new_command() functions. The highest-priority matching rule produces the corrected command, which is presented to the user or executed immediately based on configuration.

Self-Hosting & Configuration

  • Install via pip: pip install thefuck or via Homebrew: brew install thefuck
  • Initialize the alias in your shell profile with eval $(thefuck --alias)
  • Configure settings in ~/.config/thefuck/settings.py (timeout, rules, priority)
  • Set require_confirmation = False to auto-execute corrections without prompting
  • Add custom rules as Python files in ~/.config/thefuck/rules/

Key Features

  • Ships with 80+ built-in rules covering git, docker, pip, apt, cargo, and more
  • Learns from your corrections and adjusts rule priority over time
  • Supports instant mode for near-zero latency corrections
  • Custom aliases let you rename the command to anything you prefer
  • Extensible rule system with a simple two-function Python interface

Comparison with Similar Tools

  • ShellCheck — static analysis for scripts; thefuck corrects interactive commands in real time
  • zsh-autosuggestions — suggests from history; thefuck actively fixes failed commands
  • fuck (Ruby) — earlier concept; thefuck has a much larger rule library and active maintenance
  • pay-respects — Rust alternative with faster startup but fewer built-in rules

FAQ

Q: Does thefuck slow down my shell? A: In normal mode the alias only activates when you explicitly type the trigger. Instant mode adds a small hook but is designed to stay under 100ms.

Q: Can I use a different trigger word? A: Yes. Pass a custom name to the alias: eval $(thefuck --alias fix) and then type fix instead.

Q: Does it work with zsh and oh-my-zsh? A: Yes. There is also a bundled oh-my-zsh plugin for convenience.

Q: Is it safe to auto-run corrections? A: By default it asks for confirmation. You can enable auto-run, but review the rule list first to avoid surprises with destructive commands.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires