It's very common to have some kind of install commands if you're building a package, or have an extra command to generate some test data. You probably only want to run this command once. After it ran, it should never be called anymore.

There is a setHidden method, that makes it possible to hide a specific command.

Let's say we have a command that generates random data. We can check if the data exists and hide the command if it does. Once hidden is set to true the command won't show up when you run php artisan.

namespace App\Console\Commands;

use Illuminate\Console\Command;

class GenerateTestData extends Command
{
    protected $signature = 'app:generate-data';

        public function __construct()
    {
        parent::__construct();
        if (User::count() >= 5)) {
            $this->setHidden(true);
        }
    }

    public function handle()
    {
        User::factory()->count(5)->create();
    }
}

You can also do the same with the hidden property in your class definition:

class DestructiveCommand extends Command
{
    protected $signature = 'db:resetdb';
    protected $description = 'DESTRUCTIVE! do not run this unless you know what you are doing';

    // Hide this from the console list.
    protected $hidden = true;
}