With rare kudos for Congress, President Reagan signed legislation Wednesday that will provide $18 billion for a wide range of civilian and military energy and water programs.

Despite the absence of six water projects sought by the administration and the inclusion of arguable pork-barrel projects, Reagan signed the measure and urged action on the 12 remaining appropriations bills needed to finance the government through fiscal 1989.In a written statement issued as he went horseback riding and cleared brush at his 688-acre mountaintop ranch, Reagan commended lawmakers on Capitol Hill for "the responsible speed" with which the bill was passed and for keeping spending "at acceptable levels." The compliment contrasts with Reagan's previous sharp criticism of congressional budget practices.

The $18 billion in budget authority represents a $300 million cut from the administration's original request. However, Reagan noted Congress approved full funding for nuclear weapons programs, with defense accounting for $8.1 billion of the total budget authority.

He also said the overall funding levels were consistent with the deficit-reduction agreement reached with Congress last fall.

"I encourage the Congress to work with me to ensure that all remaining spending legislation complies with this agreement," he added.

Reagan and his wife, Nancy, are taking a weeklong vacation at their ranch.