Apt 2.0 introduced a new feature allowing to use smarter patterns when listing packages. This allows to list all obsolete packages using the specifier ?obsolete
or the shorthand ~o
.
$ apt list ?obsolete
It will list all locally installed packages and packages.
You can also list all packages not provided by Debian (it will also catch packages once provided by Debian but since then remove from the repositories):
$ apt list --installed "?not(?origin(debian))"