Project Lombok allows developers to add annotations to reduce boilerplate code. It works by using annotation processing at compile time to modify bytecode. Lombok provides annotations like @Getter and @Setter to automatically generate getter and setter methods. Lombok-pg extends Lombok with additional annotations. Groovy also supports compile time metaprogramming through AST transformations, allowing changes to bytecode and visibility to other JVM languages.