I want to have a class library that will run under WinRT and also Windows Phone 8. What do I need to do?
+1 on Cerebrate's answer. portable class libraries is the way to go.
However, PCL aren't a magic wand and won't bridge many of the inconsistencies between WP8 and Win8. For more hardcore code sharing you'll need to consider sharing C# files, adding conditional compilation and many other tricks. Nokia has a great article on WP7 and WP8 code sharing that would apply to this case as well @ http://www.developer.nokia.com/Resources/Library/Lumia/#!co-development-and-porting-guide.html
There's also this great Nokia Wiki article with similar intents @ http://www.developer.nokia.com/Community/Wiki/Maintaining_a_WP7_and_WP8_version_of_a_same_Silverlight_application