instinct-cli 0.3.8

Shared local memory for coding agents. Save a fix once and find it again in a new session or another connected tool.
[
{"id":"rm-unset-var","author":"Koščák Labs","title":"rm -rf on a shell variable that may be empty or unset","when":"Running rm -rf on a path built from a shell variable such as $DIR/ or \"$BUILD\"/*","found":"If the variable is unset or empty the path collapses (\"$DIR\"/* becomes /*) and rm -rf deletes from the filesystem root or the wrong directory.","how":"Make the shell refuse an empty value: rm -rf -- \"${DIR:?}\"/ . Print the expanded path with echo first, and delete a literal, checked path when you can. Under set -u an unset variable stops the script.","evidence":"https://man7.org/linux/man-pages/man1/bash.1.html","reconsider":"A literal path with no variable in it, or a variable you just checked, is fine.","tags":"tool_bash;rm;variable;cmd:rm -rf =*$|!$home/+|!${home}/+ !*:?;cmd:rm -fr =*$|!$home/+|!${home}/+ !*:?;cmd:rm -r -f =*$|!$home/+|!${home}/+ !*:?;cmd:rm -Rf =*$|!$home/+|!${home}/+ !*:?;cmd:rm -fR =*$|!$home/+|!${home}/+ !*:?;cmd:rm -f -r =*$|!$home/+|!${home}/+ !*:?;cmd:rm -rf -- =*$|!$home/+|!${home}/+ !*:?;fix:guard-var"},
{"id":"rm-root-home-glob","author":"Koščák Labs","title":"rm -rf on /, ~, * or . deletes the whole tree","when":"Running rm -rf on the filesystem root, the home directory, a bare * or the current directory","found":"rm -rf has no undo and no trash. A bare *, /*, ~ or . removes everything under it, including dotfiles and other projects. GNU rm only refuses a literal / (--preserve-root), not /* or ~.","how":"Name the exact directory you mean and list it first with ls -la. For a clean-up inside a project use git clean -n to preview, or rm -ri for a prompt per file.","evidence":"https://man7.org/linux/man-pages/man1/rm.1.html","reconsider":"Deleting a throwaway directory you created a moment ago is fine, if you name it.","tags":"tool_bash;rm;cmd:rm -rf /;cmd:rm -rf /*;cmd:rm -rf ~;cmd:rm -rf ~/;cmd:rm -rf *;cmd:rm -rf .;cmd:rm -rf ./*;cmd:rm -fr /;cmd:rm -fr ~;cmd:rm -fr *;cmd:rm -fr .;cmd:rm -Rf /;cmd:rm -Rf ~;cmd:rm -Rf *"},
{"id":"sudo-rm","author":"Koščák Labs","title":"sudo rm bypasses the permission check that would have stopped the mistake","when":"Running sudo rm to delete system files or directories","found":"Without sudo a wrong path usually fails with permission denied. With sudo the same rm deletes system libraries, package data or other users' files, and it cannot be undone.","how":"Run the rm without sudo first. If it needs root, list the path with ls -la, remove by exact path, and prefer the package manager (apt remove, brew uninstall) for installed software.","evidence":"https://www.sudo.ws/docs/man/sudo.man/","reconsider":"Removing a file you can see is yours and root-owned, by its exact path, is fine.","tags":"tool_bash;sudo;rm;cmd:sudo rm"},
{"id":"git-push-force","author":"Koščák Labs","title":"git push --force overwrites commits other people pushed","when":"Pushing with git push --force or -f after a rebase or amend","found":"--force replaces the remote branch with your local one, discarding any commit a teammate or CI pushed since you last fetched. --force-with-lease refuses when the remote moved.","how":"Use git push --force-with-lease (name the branch: --force-with-lease=main), and fetch first. Never force-push the default branch.","evidence":"https://git-scm.com/docs/git-push","reconsider":"A personal branch that only you push to is fine, though --force-with-lease costs nothing.","tags":"tool_bash;git;push;force;cmd:git push --force;cmd:git push -f;fix:force-lease"},
{"id":"git-reset-hard","author":"Koščák Labs","title":"git reset --hard throws away uncommitted work","when":"Running git reset --hard with changes in the working tree or index","found":"--hard resets the index and working tree to the target commit and discards every uncommitted change. Those changes were never committed, so reflog cannot bring them back.","how":"Run git status and git diff first. Save the work with git stash push -u or a WIP commit, or use git reset --soft or --mixed, which keep the files.","evidence":"https://git-scm.com/docs/git-reset","reconsider":"A clean tree (git status shows nothing) makes --hard safe, since reflog still has the old commit.","tags":"tool_bash;git;reset;hard;cmd:git reset --hard"},
{"id":"git-discard-all","author":"Koščák Labs","title":"git checkout . and git restore . discard all unstaged changes","when":"Running git checkout . or git restore . to undo changes in the working tree","found":"Both overwrite every modified file in the directory with the index version. The edits were never committed, so they are gone for good.","how":"Look at git diff first. Stash with git stash push, or restore one named file at a time. git restore --staged only unstages and is safe.","evidence":"https://git-scm.com/docs/git-restore","reconsider":"When you have just read git diff and want all of it gone, it is the right command.","tags":"tool_bash;git;checkout;restore;cmd:git checkout .;cmd:git checkout -- .;cmd:git restore . !--staged;cmd:git restore --worktree . !--staged"},
{"id":"git-clean-force","author":"Koščák Labs","title":"git clean -fdx deletes untracked and ignored files for good","when":"Running git clean -f, -fd or -fdx to tidy a repository","found":"Untracked files are not in any commit, and -x also removes ignored files such as .env, local databases and build caches. Nothing recovers them.","how":"Preview with git clean -nd (or -ndx). Add -e to keep patterns, or delete the named paths yourself.","evidence":"https://git-scm.com/docs/git-clean","reconsider":"After a dry run that lists only what you expect, the real run is fine.","tags":"tool_bash;git;clean;force;cmd:git clean -f;cmd:git clean -fd;cmd:git clean -df;cmd:git clean -fdx;cmd:git clean -fxd;cmd:git clean -xfd;cmd:git clean -xdf;cmd:git clean -dfx;cmd:git clean -dxf;cmd:git clean -fx;cmd:git clean -xf;cmd:git clean --force"},
{"id":"git-branch-force-delete","author":"Koščák Labs","title":"git branch -D deletes a branch even if its commits are unmerged","when":"Deleting a local git branch with git branch -D","found":"-D is --delete --force: git removes the branch without checking that it was merged, so its only copy of those commits becomes unreachable and is later garbage collected.","how":"Use git branch -d, which refuses unmerged branches. If you really mean it, note the tip with git rev-parse first so git branch name SHA can restore it.","evidence":"https://git-scm.com/docs/git-branch","reconsider":"A branch you know was squash-merged on the remote is safe to force delete.","tags":"tool_bash;git;branch;delete;cmd:git branch -D;cmd:git branch --delete --force;cmd:git branch -d -f"},
{"id":"git-push-delete","author":"Koščák Labs","title":"git push --delete removes a branch or tag on the shared remote","when":"Deleting a remote branch or tag with git push --delete or git push origin :branch","found":"The ref is removed for everyone. Open pull requests on that branch close, and colleagues' checkouts break on their next fetch.","how":"Check it is merged (git branch -r --merged) and not a PR head. Say which ref you are deleting in the command, and prefer the hosting UI for protected branches.","evidence":"https://git-scm.com/docs/git-push","reconsider":"Deleting your own merged feature branch is routine.","tags":"tool_bash;git;push;delete;cmd:git push --delete;cmd:git push -d"},
{"id":"git-stash-drop","author":"Koščák Labs","title":"git stash drop and git stash clear lose stashed work","when":"Running git stash drop or git stash clear","found":"A dropped stash is no longer reachable from any ref, and clear removes all of them at once. Only git fsck can find the dangling commits, and gc deletes them.","how":"git stash list and git stash show -p first. Apply (git stash apply) and check the result before dropping. Note the SHA that drop prints.","evidence":"https://git-scm.com/docs/git-stash","reconsider":"Dropping a stash you just applied and tested is fine.","tags":"tool_bash;git;stash;cmd:git stash drop;cmd:git stash clear"},
{"id":"git-history-rewrite","author":"Koščák Labs","title":"Expiring the reflog or pruning makes lost commits unrecoverable","when":"Running git reflog expire --expire=now, git gc --prune=now or git filter-branch","found":"The reflog is the safety net for resets and rebases. Expiring it and pruning removes unreachable commits for good, and filter-branch rewrites every commit id on the branch.","how":"Make a backup clone first (git clone --mirror). Prefer git filter-repo for rewrites, and leave gc on its default schedule.","evidence":"https://git-scm.com/docs/git-reflog","reconsider":"A deliberate purge of a leaked secret, done on a backed-up clone, is the point of these commands.","tags":"tool_bash;git;reflog;prune;cmd:git reflog expire;cmd:git gc --prune=now;cmd:git filter-branch"},
{"id":"git-add-secrets","author":"Koščák Labs","title":"Committing .env files, private keys or force-added ignored files","when":"Staging with git add .env, a private key, a .pem file or git add -f","found":"A secret that reaches a commit stays in history after you delete the file, and a pushed one must be treated as leaked. git add -f overrides .gitignore, the usual guard.","how":"Keep secrets out of the repo: add them to .gitignore, commit an .env.example, and use a secret manager. If one was committed, rotate it first, then rewrite history.","evidence":"https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository","reconsider":"A public key (.pub) or a test fixture with fake values is fine.","tags":"tool_bash;git;secret;env;cmd:git add .env;cmd:git add .env.local;cmd:git add .env.production;cmd:git add *id_rsa;cmd:git add *id_ed25519;cmd:git add *.pem;cmd:git add -f;cmd:git add --force"},
{"id":"pkill-killall","author":"Koščák Labs","title":"pkill -f and killall can kill the shell that runs them","when":"Stopping processes with pkill -f PATTERN or killall NAME","found":"pkill -f matches the whole command line, which includes the shell command running pkill itself, so the agent's own shell dies mid-script. killall NAME kills every process of that name, including other projects' and other users'.","how":"Find the exact PID with pgrep -af, check it, then kill that PID. Or use a pidfile or the service manager.","evidence":"https://man7.org/linux/man-pages/man1/pgrep.1.html","reconsider":"A pattern anchored to a unique process name, checked with pgrep first, is fine.","tags":"tool_bash;pkill;killall;cmd:pkill -f;cmd:killall;cmd:pkill -9 -f"},
{"id":"kill-all-pids","author":"Koščák Labs","title":"kill -9 -1 sends SIGKILL to every process you can signal","when":"Running kill -9 -1 or kill -KILL -1","found":"PID -1 means every process the user may signal, so it kills the login session, the agent and every other job.","how":"Kill one PID you have checked with ps -p PID, and use plain kill (SIGTERM) first.","evidence":"https://man7.org/linux/man-pages/man2/kill.2.html","reconsider":"None known; there is rarely a reason to signal every process.","tags":"tool_bash;kill;process;cmd:kill -9 -1;cmd:kill -KILL -1;cmd:kill -SIGKILL -1;cmd:kill -s KILL -1"},
{"id":"chmod-777","author":"Koščák Labs","title":"chmod 777 makes files writable by every user and process","when":"Running chmod 777 or chmod -R 777 to fix a permission error","found":"777 gives every account write access, and with -R it also marks every file executable. It hides the real problem (wrong owner), and ssh and many daemons refuse keys or configs that are group- or world-writable.","how":"Find the owner with ls -ld and fix it with chown, or grant the minimum: chmod 644 for files, 755 for directories and scripts, chmod u+x to run a script.","evidence":"https://man7.org/linux/man-pages/man1/chmod.1.html","reconsider":"A throwaway directory in a private container, and nowhere else.","tags":"tool_bash;chmod;permission;cmd:chmod 777;cmd:chmod 0777;cmd:chmod a+rwx;cmd:chmod ugo+rwx"},
{"id":"chown-recursive-system","author":"Koščák Labs","title":"chown -R on / or a system directory breaks the machine","when":"Running chown -R on /, /usr, /etc, /var, /home or another system path","found":"Recursive ownership changes on system paths break setuid binaries, sudo, ssh and package ownership. Nothing records the old owners, so it cannot be reverted by command.","how":"Change ownership only of the project directory, by exact path (chown -R user ./data). Check with ls -ld and stat first.","evidence":"https://man7.org/linux/man-pages/man1/chown.1.html","reconsider":"None for system paths; use the package manager's repair tools instead.","tags":"tool_bash;chown;owner;cmd:chown -R /;cmd:chown -R /*;cmd:chown -R /usr;cmd:chown -R /etc;cmd:chown -R /var;cmd:chown -R /home;cmd:chown -R /opt;cmd:chown -R /bin;cmd:chown -R /lib;cmd:chown -R /usr/local;cmd:chown -R .*"},
{"id":"dd-device","author":"Koščák Labs","title":"dd of=/dev/... overwrites a disk with no confirmation","when":"Writing to a block device with dd of=/dev/sdX or of=/dev/nvme0n1","found":"dd does exactly what it is told. A swapped if and of, or a wrong device letter, destroys the partition table and the data on that disk instantly.","how":"Identify the device with lsblk and check the model and size. Unmount it, double-check if= and of=, and add status=progress. For images prefer a tool that refuses mounted disks.","evidence":"https://man7.org/linux/man-pages/man1/dd.1.html","reconsider":"Writing an installer image to a removable stick that lsblk just showed is the intended use.","tags":"tool_bash;dd;disk;device;cmd:dd *of=/dev/ !*of=/dev/null;cmd:> */dev/sd;cmd:> */dev/nvme;cmd:> */dev/hd;cmd:> */dev/vd"},
{"id":"mkfs-wipefs","author":"Koščák Labs","title":"mkfs and wipefs erase the filesystem on a device","when":"Running mkfs, mkfs.ext4, mkfs.xfs, mke2fs or wipefs on a disk or partition","found":"Creating a filesystem or wiping signatures destroys access to everything on the target. A wrong device name, or a mounted device, loses the data.","how":"Check lsblk -f and mount first, confirm the device is the one you meant and unmounted. Use a loop file for tests.","evidence":"https://man7.org/linux/man-pages/man8/mkfs.8.html","reconsider":"Formatting a new, empty, verified device is the point.","tags":"tool_bash;mkfs;filesystem;format;cmd:*mkfs !man !--help;cmd:mke2fs;cmd:wipefs =-a|-af|-fa|--all|-o|-fo|-of|--offset !-n !--no-act;cmd:wipefs *--offset= !-n !--no-act"},
{"id":"sql-drop","author":"Koščák Labs","title":"DROP TABLE and DROP DATABASE delete data and structure at once","when":"Running DROP TABLE, DROP DATABASE or DROP SCHEMA through psql, mysql or sqlite3","found":"DROP removes the table, its rows, indexes and dependent objects immediately. In most databases it cannot be rolled back by the client, and CASCADE reaches further.","how":"Check the connection target (psql -c 'select current_database()') and take a backup (pg_dump). Do it inside a transaction where the engine supports DDL rollback, and never against production by hand.","evidence":"https://www.postgresql.org/docs/current/sql-droptable.html","reconsider":"Dropping a table you created minutes ago in a local scratch database is fine.","tags":"tool_bash;sql;drop;table;database;cmd:drop table;cmd:drop database;cmd:drop schema"},
{"id":"sql-truncate","author":"Koščák Labs","title":"TRUNCATE empties a table instantly and often cannot be undone","when":"Running TRUNCATE or TRUNCATE TABLE through psql or mysql","found":"TRUNCATE removes all rows without per-row logging. In MySQL it commits implicitly, and with CASCADE in PostgreSQL it empties every table that references this one.","how":"Count the rows first (SELECT count(*)), back up with pg_dump or mysqldump, check the database name, and use DELETE ... WHERE inside a transaction when you can.","evidence":"https://www.postgresql.org/docs/current/sql-truncate.html","reconsider":"A local test database you can rebuild is fine.","tags":"tool_bash;sql;truncate;table;cmd:truncate table;cmd:psql truncate;cmd:mysql truncate;cmd:psql -c truncate"},
{"id":"sql-delete-no-where","author":"Koščák Labs","title":"DELETE FROM without WHERE deletes every row","when":"Running a SQL DELETE FROM statement that has no WHERE clause","found":"A DELETE without WHERE removes every row in the table. A typo or a truncated command that loses its WHERE does the same.","how":"Write the WHERE first, run it as SELECT count(*) with the same condition, run the DELETE inside BEGIN, check the row count it reports, then COMMIT.","evidence":"https://www.postgresql.org/docs/current/sql-delete.html","reconsider":"Clearing a scratch table on purpose; use TRUNCATE on a local copy if you mean it.","tags":"tool_bash;sql;delete;where;cmd:delete from !where"},
{"id":"sql-update-no-where","author":"Koščák Labs","title":"UPDATE ... SET without WHERE changes every row","when":"Running a SQL UPDATE statement that has no WHERE clause","found":"An UPDATE without WHERE rewrites the column in every row, and the old values are not kept.","how":"Run SELECT count(*) with the intended condition first, wrap the UPDATE in BEGIN, compare the reported row count, then COMMIT or ROLLBACK.","evidence":"https://www.postgresql.org/docs/current/sql-update.html","reconsider":"A deliberate backfill of a column, in a transaction on a copy, is fine.","tags":"tool_bash;sql;update;where;cmd:update set !where"},
{"id":"terraform-destroy","author":"Koščák Labs","title":"terraform destroy removes every resource in the state","when":"Running terraform destroy or tofu destroy","found":"Destroy deletes all infrastructure the workspace manages: databases, buckets and networks. With -auto-approve there is no confirmation, and the wrong workspace or backend deletes production.","how":"Run terraform workspace show and terraform plan -destroy, read the list, and target a single resource with -target if that is all you mean. Keep the confirmation prompt.","evidence":"https://developer.hashicorp.com/terraform/cli/commands/destroy","reconsider":"Tearing down a short-lived test environment that you created is the use case.","tags":"tool_bash;terraform;destroy;cmd:terraform destroy;cmd:tofu destroy"},
{"id":"terraform-auto-approve","author":"Koščák Labs","title":"terraform apply -auto-approve skips the plan review","when":"Running terraform apply -auto-approve","found":"-auto-approve applies whatever the fresh plan contains without showing it to you. A changed variable or a drifted resource can replace or delete a database unreviewed.","how":"Save a plan with terraform plan -out=tfplan, read it, then terraform apply tfplan. Applying a saved plan needs no prompt and applies exactly what you reviewed.","evidence":"https://developer.hashicorp.com/terraform/cli/commands/apply","reconsider":"Disposable environments in CI that already gate on a reviewed plan are fine.","tags":"tool_bash;terraform;apply;approve;cmd:terraform apply -auto-approve;cmd:tofu apply -auto-approve"},
{"id":"kubectl-delete-context","author":"Koščák Labs","title":"kubectl delete without --context runs against whichever cluster is current","when":"Running kubectl delete with no --context, or kubectl delete --all or a namespace","found":"kubectl uses the current context from kubeconfig, which may be production left over from earlier. delete --all and delete namespace remove every object in scope with no further prompt.","how":"Run kubectl config current-context, pass --context and -n explicitly, and look first with kubectl get and --dry-run=server.","evidence":"https://kubernetes.io/docs/reference/kubectl/generated/kubectl_delete/","reconsider":"A throwaway local cluster (kind, minikube) is fine.","tags":"tool_bash;kubectl;delete;cluster;cmd:kubectl delete !*--context;cmd:kubectl delete --all;cmd:kubectl delete namespace;cmd:kubectl delete ns"},
{"id":"docker-system-prune","author":"Koščák Labs","title":"docker system prune -a --volumes deletes images and volume data","when":"Running docker system prune -a or --volumes, or docker volume prune","found":"With -a it removes every image not used by a running container, and --volumes also removes unused volumes, which is where databases keep their data. There is no undo.","how":"List first: docker system df, docker volume ls, docker ps -a. Prune one class on purpose (docker image prune, docker builder prune), and keep --volumes off unless you checked each volume.","evidence":"https://docs.docker.com/reference/cli/docker/system/prune/","reconsider":"A CI runner or disposable dev box is fine.","tags":"tool_bash;docker;prune;volume;cmd:docker system prune -a;cmd:docker system prune --all;cmd:docker system prune --volumes;cmd:docker volume prune"},
{"id":"compose-down-volumes","author":"Koščák Labs","title":"docker compose down -v deletes the named volumes","when":"Running docker compose down -v or --volumes","found":"down removes containers and networks; with -v it also removes the named volumes declared in the compose file, which is the database data.","how":"Use docker compose down alone to stop the stack. Back up the volume (docker run --rm -v VOL:/d -v $PWD:/b alpine tar czf /b/vol.tgz /d) before deleting it.","evidence":"https://docs.docker.com/reference/cli/docker/compose/down/","reconsider":"A throwaway test stack whose data you can regenerate.","tags":"tool_bash;docker;compose;volume;cmd:docker compose down -v;cmd:docker compose down --volumes;cmd:docker-compose down -v;cmd:docker-compose down --volumes"},
{"id":"curl-pipe-shell","author":"Koščák Labs","title":"curl | sh runs a remote script before you have read it","when":"Piping curl or wget output into sh or bash to install something","found":"The script runs immediately, as you or as root with sudo, and a connection that drops mid-download can run a truncated script. The server can also serve different content to curl than to a browser.","how":"Download first (curl -fsSLo install.sh URL), read it, check a published checksum or signature, then run it. Prefer the package manager or a pinned release.","evidence":"https://curl.se/docs/manpage.html","reconsider":"A vendor script you have already audited and pinned by hash.","tags":"tool_bash;curl;wget;install;pipe;cmd:curl sh;cmd:curl bash;cmd:wget sh;cmd:wget bash;cmd:sh -c curl;cmd:bash -c curl"},
{"id":"npm-publish","author":"Koščák Labs","title":"npm publish uploads whatever is on disk, and it is hard to take back","when":"Running npm publish, pnpm publish or yarn publish","found":"The tarball is built from the working directory, so uncommitted files and local config can ship, and a published version cannot be republished. Unpublishing is limited by registry policy.","how":"Run npm publish --dry-run and npm pack to read the file list, check git status is clean and the version is bumped, and publish from CI with provenance.","evidence":"https://docs.npmjs.com/cli/commands/npm-publish","reconsider":"A reviewed release from a clean tag.","tags":"tool_bash;npm;publish;package;cmd:npm publish !--dry-run;cmd:pnpm publish !--dry-run;cmd:yarn publish"},
{"id":"cargo-publish","author":"Koščák Labs","title":"cargo publish is permanent, and --allow-dirty ships uncommitted files","when":"Running cargo publish, especially with --allow-dirty","found":"A version on crates.io can be yanked but never deleted or replaced. --allow-dirty lets cargo package files that are not committed, so local edits and generated files go public.","how":"Run cargo publish --dry-run and cargo package --list first, make sure git status is clean, and publish from a tagged commit. Never pass --allow-dirty.","evidence":"https://doc.rust-lang.org/cargo/commands/cargo-publish.html","reconsider":"A reviewed release from a clean tag.","tags":"tool_bash;cargo;publish;crate;cmd:cargo publish !--dry-run"},
{"id":"redirect-overwrite","author":"Koščák Labs","title":"> overwrites a config or shell rc file where >> would append","when":"Writing to ~/.bashrc, ~/.zshrc, authorized_keys, /etc/hosts or .gitignore with echo ... > file","found":"A single > truncates the file first. Appending a line to .bashrc or authorized_keys with > replaces everything that was there, and a lock-out follows.","how":"Use >> to append, or tee -a. Copy the file to a backup first, and set -o noclobber to make > refuse existing files.","evidence":"https://man7.org/linux/man-pages/man1/bash.1.html","reconsider":"When the file is generated and you want to replace it, write to a temp file and move it into place.","tags":"tool_bash;redirect;overwrite;config;cmd:> *.bashrc;cmd:> *.zshrc;cmd:> *.profile;cmd:> *.bash_profile;cmd:> *authorized_keys;cmd:> /etc/hosts;cmd:> /etc/fstab;cmd:> *.gitignore;cmd:> *.npmrc"},
{"id":"sed-in-place","author":"Koščák Labs","title":"sed -i edits files in place with no backup","when":"Running sed -i over a glob or many files","found":"-i with no suffix rewrites each file immediately. A wrong regex corrupts every file it touches, and if the files are not in git there is no way back. Behaviour of -i also differs between GNU and BSD sed.","how":"Preview with sed -n 's/old/new/p' first, use -i.bak (one word) or run it in a clean git tree so git diff shows the result, and check with git diff before moving on.","evidence":"https://man7.org/linux/man-pages/man1/sed.1.html","reconsider":"A single file in a clean git tree is easy to undo.","tags":"tool_bash;sed;edit;inplace;cmd:sed -i;cmd:sed -ri;cmd:sed --in-place"},
{"id":"find-delete","author":"Koščák Labs","title":"find -delete and find -exec rm remove files as they are matched","when":"Running find ... -delete or find ... -exec rm or xargs rm","found":"-delete acts as soon as the expression reaches it, so placed before the tests it deletes everything under the start point, and a wrong -name or path removes more than meant. There is no trash.","how":"Run the same find with -print first and read the list, put -delete last, add -maxdepth, and use -type f.","evidence":"https://man7.org/linux/man-pages/man1/find.1.html","reconsider":"A list you just printed and checked.","tags":"tool_bash;find;delete;files;cmd:find <=-name|-iname|-path|-ipath|-wholename|-iwholename|-regex|-iregex|-type|-xtype|-mtime|-atime|-ctime|-mmin|-amin|-cmin|-newer|-anewer|-cnewer|-size|-user|-group|-uid|-gid|-perm|-empty|-lname|-ilname|-samefile|-inum|-links|-nouser|-nogroup|-executable|-readable|-writable|-used|-fstype <*-newer -delete;cmd:find -exec rm;cmd:xargs rm"},
{"id":"aws-s3-delete","author":"Koščák Labs","title":"aws s3 rm --recursive and sync --delete remove bucket objects","when":"Running aws s3 rm --recursive, aws s3 rb --force or aws s3 sync --delete","found":"These delete every object under the prefix, or every destination object missing from the source. Without bucket versioning the objects are gone, and a wrong prefix or swapped source and destination deletes the real data.","how":"Add --dryrun first and read the output. Check the bucket, prefix and the versioning setting, and enable versioning before bulk deletes.","evidence":"https://docs.aws.amazon.com/cli/latest/reference/s3/rm.html","reconsider":"A scratch bucket you created.","tags":"tool_bash;aws;s3;delete;cmd:aws s3 rm --recursive !--dryrun;cmd:aws s3 rb --force;cmd:aws s3 sync --delete !--dryrun"},
{"id":"rsync-delete","author":"Koščák Labs","title":"rsync --delete removes destination files missing from the source","when":"Running rsync -a --delete between two directories","found":"--delete makes the destination match the source. A trailing slash that is missing or extra, or swapped arguments, can empty the destination.","how":"Run it with -n (--dry-run) -v first and read what would be deleted. Keep the trailing slashes deliberate and use --backup.","evidence":"https://download.samba.org/pub/rsync/rsync.1","reconsider":"A mirror target that is meant to be disposable and has a backup.","tags":"tool_bash;rsync;delete;mirror;cmd:rsync --delete !--dry-run !-n;cmd:rsync --delete-before !--dry-run !-n;cmd:rsync --delete-after !--dry-run !-n;cmd:rsync --delete-excluded !--dry-run !-n"},
{"id":"redis-flush","author":"Koščák Labs","title":"FLUSHALL and FLUSHDB empty a Redis instance","when":"Running redis-cli FLUSHALL or FLUSHDB","found":"FLUSHALL deletes every key in every database on the server, FLUSHDB the current one. Caches, queues and sessions go with them, and production keys share the instance with test keys more often than expected.","how":"Check redis-cli -n N dbsize and INFO keyspace, confirm the host with redis-cli CONFIG GET bind, delete by pattern with SCAN, and use FLUSHALL ASYNC only on a disposable instance.","evidence":"https://redis.io/docs/latest/commands/flushall/","reconsider":"A local development Redis.","tags":"tool_bash;redis;flush;cache;cmd:redis-cli flushall;cmd:redis-cli flushdb"},
{"id":"detached-launch-unbound","author":"Koščák Labs","title":"nohup, setsid, disown and (cmd &) start a process that outlives its session and nothing ends it","when":"Running nohup cmd &, setsid cmd, cmd & disown, (cmd &), ssh -f, or sleep infinity / tail -f /dev/null in the background without a timeout, a trap that kills it, a saved PID that is waited or killed, or a systemd scope","found":"These forms cut the process loose from the shell that started it. When the session, script or agent ends, nothing stops it: it keeps its CPU, memory, ports and files open for hours or days, and the next run starts a second copy. Agents leave these behind because the launching command returns at once and looks finished.","how":"Tie the launch to a lifetime. Use `timeout 600 cmd &`, or `cmd & p=$!; trap \"kill $p\" EXIT` and later `wait $p`, or `systemd-run --user --scope -p RuntimeMaxSec=600 cmd`. Record the PID where you can find it, and stop the process when the work is done.","evidence":"https://www.freedesktop.org/software/systemd/man/latest/systemd-run.html","reconsider":"A long-lived service you mean to keep running, started on purpose and registered with a service manager or documented stop command.","tags":"tool_bash;nohup;setsid;disown;background;orphan;cmd:nohup __bg__ !timeout !trap !systemd-run !wait !kill !pkill !killall;cmd:setsid !timeout !trap !systemd-run !wait !kill !pkill !killall !-w !--wait !commit !tag !merge !-am !--message !--body;cmd:disown !timeout !trap !systemd-run !wait !kill !pkill !killall !commit !tag !merge !-am !--message !--body;cmd:__subbg__ !timeout !trap !systemd-run !wait !kill !pkill !killall;cmd:sleep infinity __bg__ !timeout !trap !systemd-run !wait !kill !pkill !killall;cmd:tail =-f|-F|--follow /dev/null __bg__ !timeout !trap !systemd-run !wait !kill !pkill !killall;cmd:ssh =-f|-fn|-nf|-fnt|-fng|-fnl|-fnr !timeout !trap !systemd-run !wait !kill !pkill !killall"},
{"id":"headless-browser-background","author":"Koščák Labs","title":"A headless browser started in the background from a script is an orphan when the script ends","when":"Running chromium, google-chrome, firefox or another browser with --headless or --remote-debugging-port in the background (&, nohup, setsid) without a timeout, a trap that kills it, or a saved PID that is killed","found":"A browser launched this way keeps running after the script or agent exits, with its profile lock, debugging port and child processes. Headless browsers found open for many hours are almost always left over from a script that never closed them.","how":"Bind the browser to the script: `timeout 120 chromium --headless ... &`, or `chromium --headless ... & b=$!; trap \"kill $b\" EXIT`, or run it in the foreground with --dump-dom or --screenshot. Close it when the page work is done, and use a throwaway --user-data-dir.","evidence":"https://developer.chrome.com/docs/chromium/headless","reconsider":"A browser you want to keep open on purpose for debugging, started by you and closed by you.","tags":"tool_bash;headless;browser;background;orphan;cmd:=*chrom|*firefox|*brave|*msedge|*vivaldi|*opera =*--headless|*--remote-debugging-port __bg__ !timeout !trap !systemd-run !wait !kill !pkill !killall;cmd:=*chrom|*firefox|*brave|*msedge|*vivaldi|*opera =*--headless|*--remote-debugging-port disown !timeout !trap !systemd-run !wait !kill !pkill !killall"},
{"id":"home-wipe","author":"Koščák Labs","title":"rm -rf on a whole home directory or everything in it","when":"Running rm -rf on ~/*, $HOME, $HOME/*, /home/NAME, /Users/NAME or the contents of one of them, with or without sudo","found":"This removes documents, SSH keys, shell config, browser profiles and every project the user owns, and there is no trash and no undo. It happens when an agent cleans up after itself with a path that was meant to be a subfolder, or with a variable that held the wrong value.","how":"Delete the exact subfolder you created, for example rm -rf ~/project/build, and list it first with ls -la. Never clean up above the project directory. If a script needs a cleanup step, keep the path in a variable that is checked non-empty and inside the project.","evidence":"https://man7.org/linux/man-pages/man1/rm.1.html","reconsider":"A throwaway home directory of a test user or container that you created for this run and can recreate.","tags":"tool_bash;rm;home;cmd:rm =-r|-rf|-fr|-rv|-vr|-rfv|-rvf|-frv|-fvr|-vrf|-vfr|-ri|-ir|-rfi|-rif|-fri|-fir|-irf|-ifr|--recursive =~/*|~/.*|$home|$home/*|${home}|${home}/*|${home:?}|${home:?}/*|/home/?|/home/?/*|/users/?|/users/?/*|/root|/root/*|/home|/home/*|/users|/users/*"},
{"id":"windows-delete","author":"Koščák Labs","title":"rmdir /s /q, del /s /q and Remove-Item -Recurse -Force delete a tree with no prompt","when":"Running rmdir /s /q, rd /s /q, del /s /q, or PowerShell Remove-Item (or ri, rm, del) with -Recurse and -Force","found":"The quiet and force switches skip every confirmation and the recursive switch walks the whole tree, so a wrong or too short path removes a drive root, a user profile or a project with all its subfolders. Nothing goes to the Recycle Bin. Directory junctions inside the tree can lead the delete outside it.","how":"Print the target first with dir or Get-ChildItem. Test the delete with Remove-Item -WhatIf, name the full path of one subfolder, and avoid /q and -Force until the listing is what you expect. Check for junctions before deleting a tree you did not create.","evidence":"https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/remove-item","reconsider":"A build or temp folder you created in this run, named by its full path.","tags":"tool_bash;windows;powershell;delete;cmd:=rmdir|rd|del|erase =/s =/q =*:\\|*:/|*%|*$|*..|*~|**|*?|\\+;cmd:=rmdir|rd|del|erase =/q =/s =*:\\|*:/|*%|*$|*..|*~|**|*?|\\+;cmd:=rmdir|rd|del|erase =/s/q|/q/s =*:\\|*:/|*%|*$|*..|*~|**|*?|\\+;cmd:=rmdir|rd|del|erase =*:\\|*:/|*%|*$|*..|*~|**|*?|\\+ =/s =/q;cmd:=rmdir|rd|del|erase =*:\\|*:/|*%|*$|*..|*~|**|*?|\\+ =/q =/s;cmd:=rmdir|rd|del|erase =*:\\|*:/|*%|*$|*..|*~|**|*?|\\+ =/s/q|/q/s;cmd:=remove-item|ri|rm|del|erase|rmdir|rd =-r^ecurse =-fo^rce =*:\\|*:/|*%|*$|*..|*~|**|*?|\\+ !=-w^hatif;cmd:=remove-item|ri|rm|del|erase|rmdir|rd =-fo^rce =-r^ecurse =*:\\|*:/|*%|*$|*..|*~|**|*?|\\+ !=-w^hatif;cmd:=remove-item|ri|rm|del|erase|rmdir|rd =*:\\|*:/|*%|*$|*..|*~|**|*?|\\+ =-r^ecurse =-fo^rce !=-w^hatif;cmd:=remove-item|ri|rm|del|erase|rmdir|rd =*:\\|*:/|*%|*$|*..|*~|**|*?|\\+ =-fo^rce =-r^ecurse !=-w^hatif"},
{"id":"cloud-destroy","author":"Koščák Labs","title":"aws, gcloud and az delete commands destroy cloud resources","when":"Running aws ec2 terminate-instances, aws iam delete-*, aws rds delete-db-instance or delete-db-cluster, aws cloudformation delete-stack, gcloud projects delete, gcloud compute instances delete, gcloud sql instances delete, or az group delete","found":"These calls act on the real account at once. Terminating an instance drops its instance-store data, deleting a database can take its automated backups with it, and deleting a stack, a project or a resource group removes everything inside, usually with no confirmation. The CLI uses whichever profile or project is active, which may be production.","how":"Run the matching describe, list or get command first and read what will go. Check the active account with aws sts get-caller-identity, gcloud config list or az account show. Take a snapshot or final backup, turn on termination protection or deletion protection, and delete one named resource, not a group.","evidence":"https://docs.aws.amazon.com/cli/latest/reference/ec2/terminate-instances.html","reconsider":"A resource you created in a sandbox account in this session.","tags":"tool_bash;aws;gcloud;azure;cloud;delete;cmd:aws ec2 terminate-instances !--dry-run;cmd:aws iam *delete-;cmd:aws rds delete-db-instance;cmd:aws rds delete-db-cluster;cmd:aws cloudformation delete-stack;cmd:gcloud projects delete;cmd:gcloud compute instances delete;cmd:gcloud sql instances delete;cmd:az group delete"},
{"id":"discard-files","author":"Koščák Labs","title":"git restore PATH and git checkout -- PATH throw away uncommitted edits","when":"Running git restore on files, or git checkout -- on files, without --staged","found":"Both overwrite the working copy of the named files with the committed or staged version. Edits that were never committed are not in the reflog, so they cannot be recovered, and an agent often runs it to undo its own change and takes your work with it.","how":"Run git diff on the paths first and read what will be lost. Save the edits with git stash push -- PATH or a throwaway commit before you restore. To only unstage, use git restore --staged PATH.","evidence":"https://git-scm.com/docs/git-restore","reconsider":"A file the agent just generated that you have already looked at, or one you want reset on purpose.","tags":"tool_bash;git;restore;checkout;discard;cmd:git restore !--staged !-S !--patch !-p !--help;cmd:git restore --worktree;cmd:git restore -W;cmd:git checkout --"},
{"id":"wait-no-deadline","author":"Koščák Labs","title":"A poll loop with no deadline, or a slow command in the foreground, stalls the agent","when":"Running until/while ... sleep to wait for something, pgrep -f inside such a loop, or a command that usually takes over 30 s","found":"A loop with no deadline runs forever when the awaited thing never happens. pgrep -f in a loop matches the loop's own command line, so it never ends. A foreground command that takes minutes freezes the turn.","how":"Give every poll a deadline (timeout 600 ...), use pgrep -A -f so the loop ignores itself, and run slow commands in the background. instinct guard applies these three fixes for you before the command runs (INSTINCT_FIX=0 turns that off).","evidence":"https://man7.org/linux/man-pages/man1/pgrep.1.html","reconsider":"A daemon-style loop that is meant to run until stopped.","tags":"tool_bash;wait;poll;deadline;cmd:until sleep !timeout !*SECONDS;cmd:while sleep !timeout !*SECONDS;fix:pgrep-A;fix:loop-timeout;fix:bg-slow"}
]