Preheat the oven to 350°F (175°C). Line a baking sheet with parchment paper.
In a medium bowl, whisk together flour, baking soda, cinnamon, nutmeg, and salt.
In a large bowl, beat together butter and brown sugar until light and fluffy, about 2-3 minutes.
Add the egg and vanilla extract, and mix until well combined.
Gradually add the dry ingredients to the wet mixture and stir until just combined.
Fold in the grated carrots and optional raisins or walnuts.
Using a cookie scoop, drop tablespoon-sized portions of dough onto the prepared baking sheet, spacing them about 2 inches apart.
Bake for 10-12 minutes, or until the cookies are golden and set around the edges.
Let the cookies cool on the baking sheet for 5 minutes, then transfer to a wire rack to cool completely.
While the cookies are cooling, prepare the cream cheese frosting by beating together cream cheese, butter, powdered sugar, and vanilla extract until smooth.
Once the cookies are completely cool, spread a generous amount of frosting onto the bottom of one cookie and sandwich it with another.