Deductions & credits

I'm a retired IRS Revenue Agent - funny you should ask.

First off all the IRS will know is the sale of the house from the F1099 you receive from the sale.  Its up to you to keep all you tax records from the purchase of the house to the sale of the house.  

You get to add to the basis any capital improvements to the house such as remodel or even a new roof. 

From the sale of the house you get to deduct any expenses such as commissions and any repairs including repainting to sell the house. 

How does the IRS know what you paid -  It has access to various records that report sales amount and property tax amounts.  So when you remodel your house and get a building permit it shows up on the database the IRS uses.  It also uses the sales of other houses from other taxpayers.  You are not the only or first house ever sold.  The IRS knows from history that people who own and live in a house for 20 years may have remodeled once or twice (kitchen and bathroom) and maybe replaced the roof on a 100 year old house or even a 30 year old house.  If the amount added is within parameters it is usually accepted. 

But remember your return could be selected for any reason and if selected everything on the return is subject to review (audit).  Keep all your tax records (including the purchase and sale ) for 7 years after you report the sale.