In a Chapter 7 bankruptcy, the debtor is required to list all debts and assets, including property. The court issues a stay, banning any collection activity or lawsuits by your creditors, and then assigns a trustee to liquidate your assets in order to pay any secured debts. Unsecured debts are discharged at the end of the process, which results in a financial "clean slate." The laws of the states govern which property is exempt from seizure by the trustee; in all states a personal, primary residence is exempt and safe from foreclosure -- until the discharge.
During a bankruptcy, the debtor may enter into a reaffirmation agreement with any secured creditor. This is a pledge to continue regular payments after the bankruptcy, and is most often used for personal property, such as a car or boat, which the debtor wants to keep. The court must approve any reaffirmation agreements, which protect the creditors from a discharge of their loans. You may also sign a reaffirmation agreement with a mortgage lender, promising to keep up the payments and not to walk away from the loan.
Pros and Cons
A reaffirmation agreement with a mortgage lender means you agree to keep up payments, and that the court will not discharge the loan. Since the lender will still have a lien on the property, however, you risk foreclosure if you cease payments after the bankruptcy, with or without a reaffirmation agreement. The upside is that the lender continues reporting your loan as current to the credit bureaus. The risk is that you fall behind on the payments after the bankruptcy and lose the house anyway - and by terms of the reaffirmation agreement, remain liable for some or all of the outstanding balance.
You may consider reaffirmation as a courtesy to the lender, in return for which the lender reports your good-faith effort to keep up on the loan. But mortgage lenders don't typically require reaffirmation agreements by debtors in bankruptcy, although they may ask for one in order to continue sending out statements and reporting payments. There's little risk that a mortgage lender will foreclose on a property if you continue payments, with or without a reaffirmation agreement. The bank or mortgage company wants to avoid foreclosure if at all possible, and also wants to avoid the legal fees associated with lawsuits against debtors.