Preheat your oven to 350°F (175°C).
Grease a large baking dish with nonstick spray or olive oil.
In a large skillet over medium heat, add olive oil and sauté chopped onions until translucent.
Add minced garlic and sauté until aromatic.
Add ground beef and sliced mushrooms; cook until browned and fully cooked through.
In a large bowl, combine cooked pasta or rice with sautéed beef mixture.
Season with salt, pepper, thyme, and any preferred spices.
Transfer everything into the greased baking dish.
Top generously with shredded cheddar cheese.
Bake for about 25-30 minutes or until bubbly and golden brown.