Wash, peel, and finely grate the carrots. Gently blot them with a paper towel to remove excess moisture. Avoid squeezing them completely dry because the natural moisture helps keep the cookies soft.
In a medium bowl, whisk together the flour, baking soda, baking powder, cinnamon, nutmeg, and salt. Set the mixture aside while you prepare the wet ingredients.
In a large mixing bowl, beat the softened butter, brown sugar, and granulated sugar until creamy and well combined. This usually takes about 2–3 minutes with an electric mixer.
Beat in the egg and vanilla extract until the mixture looks smooth. Scrape down the sides of the bowl so the ingredients are evenly incorporated.
Gradually add the dry ingredients to the butter mixture. Stir until just combined, then fold in the grated carrots, walnuts, and raisins if using. The dough should be soft and slightly sticky.
Refrigerate the dough for about 20 minutes. Chilling helps control spreading and makes the dough easier to portion. Meanwhile, preheat the oven to 350°F (175°C) and line a baking sheet with parchment paper.
Scoop approximately 1½ tablespoons of dough for each cookie and place the portions about 2 inches apart on the prepared baking sheet. Bake for 12–15 minutes, until the edges are set and lightly golden while the centers remain soft.
Allow the cookies to rest on the baking sheet for 5 minutes before transferring them to a wire rack. Let them cool completely before frosting to prevent the cream cheese topping from melting.
Beat the softened cream cheese and butter until smooth. Add the powdered sugar and vanilla extract, then beat until creamy. If the frosting is too thick, add a little milk, one teaspoon at a time.
Spread or pipe a small amount of cream cheese frosting onto each cooled cookie. For extra decoration, sprinkle chopped walnuts or a light dusting of cinnamon over the top. Serve immediately or refrigerate until ready to enjoy.