Things to do before you file
If you have some credit card accounts in good standing with zero balances, stop using them. Keep those accounts clean. If the balance is very low, maybe a few hundred dollars, paying it off may be a very good investment towards improving your credit after the bankruptcy is finished. Most financial institutions will keep a person's account open even though they have filed bankruptcy, so long as there was nothing owed on the date that the case was filed in court. However, it could be a mistake to pay off an account if the amount you owe is more than a few hundred dollars. Always check with your own bankruptcy attorney before doing this, and let your own lawyer advice you.
Things to do during the bankruptcy
If you have a car loan or a car lease that has always been paid on time, you can usually gain considerable good credit if you reaffirm the loan or the lease. That way future car payments will probably be reflected favorably on your credit. Of course a person probably should not do this if the payments present a hardship or if there are other reasons why keeping the vehicle will be undesireable. Always check with your own bankruptcy attorney before doing this, and let your own lawyer advice you.
Things to do after the bankruptcy
There are a few things to do after the bankruptcy that can help you. Most people receive credit card solicitations as soon as their bankruptcy is completed. BEWARE of such offers, as a high percentage of such offerings are bogus. If they are a legitimate credit card, they might not do you any good. For example, most such offers will provide a very tiny credit limit, maybe just 1 or 2 hundred dollars and require very high annual fees, like $50 or $75. You should stay away from those. Another problem is that many of these credit cards are not even reported to the credit bureaus, so they won't even help your credit even if you do get them. Don't accept any such credit card offer unless you can verify with the card issuer that the account will be reported on your credit.
Keep your credit looking good after you get it back
Once the bankruptcy is finished, it will be vital to your future credit life that you always pay your obligations on time. Whether you have reaffirmed a car loan, use a credit card that you retained, or a new credit card that was issued after the bankruptcy, don't screw up. If you have any late pays, you are probably going to wreck your chances of rebuilding credit for a long time to come. Pay on time, pay early, don't ever be late, and you may work miracles at rebuilding your credit faster than you ever expected.